There are several 'layers' in
R. For example:
If you create a function, it is positioned in the global environment.
Everything that happens in a function, stays in a function. Unless you specifically tell the function to share the information with the global environment.
Packages have their own space.
this is important, because different packages may have functions with the same name.
for example, summary() is a function in both package lavaan and package lme4.
If you load package lavaan, and then package lme4, the summary function will refer to the one in package lme4.
but you can use both by using: lavaan::summary() and lme4::summary()
A workspace contains all changes you made to environments.
You can save a workspace and continue exactly where you left.
Workspaces are compressed and require relatively little memory when stored.
R by default saves (part of) the code history. (Use up arrow key in the console)
savehistory(file = "Stuff.Rhistory")
loadhistrory(file = "Stuff.Rhistory")
You can load .Rdata files with function
save(object1,object2,object3, file = "savedobjects.Rdata")
You can load such files with function
write.table(object1, file = "savedobject.csv", sep=";", col.names = TRUE, row.names=FALSE)
read.table(file="savedobject.csv", sep=";", header=TRUE)