This function tells R to load packages and library folders at the start of every session (or on a per-project basis). It's best to keep this auto-load list to a minimum so that you don't forget to explicitly install/attach packages in scripts that need them.
lib_startup(..., lib = lib_paths(), global = TRUE)
(Names) Packages as bare names. For packages that come from GitHub, you can
keep the username/package format, or omit the username and provide just the package
name. If you leave ...
blank, R will only load its default packages (see Details).
(Character) The path where packages are installed. Can be an
absolute or relative path. If path
has more than one element, only the first
one will be kept. Tilde expansion is performed on the input, but wildcard expansion
(globbing) is not. Defaults to the current library search path.
(Logical) If TRUE
, write these settings to a .Rprofile file in the home
directory (on Windows, the My Documents folder). If FALSE
, write them to a
.Rprofile file that is in the current directory (i.e. the RStudio project's folder,
or the current working directory). See Details for more.
A message listing the values that were written to the .Rprofile file.
R's startup order is mentioned in ?Startup
, but briefly:
R tries to load the environmental variables file (Renviron.site)
R tries to load the site-wide profile (Rprofile.site)
R tries to load the user profile (.Rprofile), first in the current directory, and then in the user's home directory (on Windows, the My Documents folder). Only one of these files is sourced into the workspace.
Omitting ...
makes R load only its default packages. If these are not set in an
environmental variable (R_DEFAULT_PACKAGES
), then R will default to loading these
packages: datasets, utils, grDevices, graphics, stats, and methods.
# NOT RUN {
#> lib_startup(librarian, magrittr, lib = "C:/Dropbox/My R Library")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab