Could you suggest me a way for loading packages in R automatically? I mean, I want to start a session in R without needing to use library('package name') several times. Suppose I downloaded all packages I’ll want to use the next time I start R.
Could you suggest me a way for loading packages in R automatically? I mean,
Share
Put
library(foo)in your.Rprofilefile or setR_DEFAULT_PACKAGES: see?Rprofile…In particular (because
?Rprofileis long and potentially intimidating):Since you probably do want all of the default packages loaded, and then extra ones in addition (rather than, say, not loading some of the default packages), you can either put
or using
options(defaultPackages=...):in your
.Rprofileto append your desired packages to the standard defaults.edit (copied from comment) re getting this to work in Rstudio:
http://rstudio.org/docs/using/workspaces suggests that Rstudio executes
.Rprofileand then “Performs the other actions described in R Startup [ http://stat.ethz.ch/R-manual/R-patched/library/base/html/Startup.html ]” (which is the same as?Rprofile). It is ambiguous whether it looks atRprofile.siteor not.edit #2: according to comment below, it does work with a recent version of Rstudio.