Section 14 Housekeeping Functions
14.1 R Environment
To see the R objects created in the current session:
objects()
To list all R objects:
ls()
ls()
andobjects()
return a vector of character strings giving the names of the objects in the specified environment.To remove an R object:
rm(list=c('a','b'))
wherea
andb
are two R objectsTo remove all R objects in the current session:
rm(list=ls())
To see which packages and dataframes are currently attached:
search()
Details of the R session:
sessionInfo()
14.2 Save Script
The easiest way to save the script is to save the file as a .R file within the RStudio environment.
The RStudio environment will display an asterisk when the current script is not saved.
14.3 Save History
The easiest way to save the history is to save the file as a .Rhistory file within the RStudio environment.
The function
savehistory
can be used to save the history using the function.The function
loadhistory
helps to load a previously saved history.