When I included janitor package with other packages, it did not load.
library(MASS, caret, stepPlr, janitor)
> library(janitor)
Warning message:
package ‘janitor’ was built under R version 3.3.3
The library()
function isn't meant to load multiple libraries, a better approach is to create a list of packages, and use require()
to check if they are installed and if not install them. See example below:
requiredPackages <- c("MASS", "caret", "stepPlr", "janitor")
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
ipak(requiredPackages)