lib_startup: Set packages and library paths to automatically start-up with...

Description Usage Arguments Details Value Examples

View source: R/exported_functions.R

Description

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.

Usage

1
lib_startup(..., lib = lib_paths(), global = TRUE)

Arguments

...

(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).

lib

(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.

global

(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.

Details

R's startup order is mentioned in ?Startup, but briefly:

  1. R tries to load the environmental variables file (Renviron.site)

  2. R tries to load the site-wide profile (Rprofile.site)

  3. 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.

Value

A message listing the values that were written to the .Rprofile file.

Examples

1
#> lib_startup(librarian, magrittr, lib = "C:/Dropbox/My R Library")

librarian documentation built on July 12, 2021, 5:07 p.m.