p_load: Load One or More Packages

Description Usage Arguments See Also Examples

Description

This function is a wrapper for library and require. It checks to see if a package is installed, if not it attempts to install the package from CRAN and/or any other repository in the pacman repository list.

Usage

1
2
p_load(..., char, install = TRUE, update = getOption("pac_update"),
  character.only = FALSE)

Arguments

char

Character vector containing packages to load. If you are calling p_load from within a function (or just having difficulties calling it using a character vector input) then pass your character vector of packages to load to this parameter directly.

install

logical. If TRUE will attempt to install a package not found in the library.

update

logical. If TRUE will attempt to update all out of date packages. Default allows the user to set a "pac_update" in his/her .Rprofile.

character.only

logical. If TRUE then p_load will only accept a single input which is a character vector containing the names of packages to load.

...

name(s) of package(s).

See Also

library, require, install.packages

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
p_load(lattice)
p_unload(lattice)
p_load(lattice, foreign, boot, rpart)
p_loaded()
p_unload(lattice, foreign, boot, rpart)
p_loaded()

## End(Not run)

Example output

The following packages have been unloaded:
lattice

[1] "rpart"   "boot"    "foreign" "lattice" "pacman" 
The following packages have been unloaded:
lattice, foreign, boot, rpart

[1] "pacman"

pacman documentation built on May 2, 2019, 1:08 p.m.