Preliminaries
- install.packages("package_name",dependencies = TRUE) # install package
- library(package_name) # load package
- search() # list all packages attached
- ls() # list all objects in environment/package
- help(name) # help on package/function
- getwd() # get working directory
- list.files() # list files in working directory
- save.image() # save workspace to .Rdata
- savehistory() # save history to .Rhistory
Data types
- class(obj) # class of object
- dim() # dimension of matrix
- length() # length of array
- factor() # encode categorical variables using numeric storage (e.g. "red","orange","green")