december 2015
<-
)R
-scriptsobjectname[2,4]
)R
R
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")
R
save()
.You can load .Rdata files with function load()
save(object1,object2,object3, file = "savedobjects.Rdata")
load(file="savedobjects.Rdata")
write.table()
.You can load such files with function read.table()
write.table(object1, file = "savedobject.csv", sep=";", col.names = TRUE, row.names=FALSE)
read.table(file="savedobject.csv", sep=";", header=TRUE)
General tutorials
When you are stuck
Some things we did not do in this course, that may become important:
Rstudio
Exercise 1 is a recap of last week: Try to make Exercise 1 without looking at the answers.
There probably is not enough time to do all the exercises. Pick the ones that interest you.
- Exercise 2: Loading spss data, recoding items, making sum score variables - Exercise 3: More elaborate regression analysis in R - Exercise 4: ANOVA in R - Exercise 5: Basic SEM in R with lavaan. - Exercise 6: Basic multilevel modeling in R with lme4.
After you've tried an exercise you can try something similar with your own data.