Re: [R] Loading multiple packages with install.packages()...

2024-09-23 Thread Ben Bolker
Continuing with this approach: a1 <- available.packages() packages <- grep("^rcmdrplugin", rownames(a1), ignore.case = TRUE, value = TRUE) missing_pkgs <- setdiff(packages, rownames(installed.packages())) install.packages(missing_pkgs, dependencies = TRUE) The pacman package also handles s

Re: [R] Loading multiple packages with install.packages()...

2024-09-23 Thread Bert Gunter
"If you can get a vector with all the package names (I do not know how to do this)..." See ?available.packages grep-ing the rownames of the available.packages() result appropriately should give you a vector of the desired package names to install, which can then be given to install.packages. ...

Re: [R] Loading multiple packages with install.packages()...

2024-09-23 Thread Ebert,Timothy Aaron
If you can get a vector with all the package names (I do not know how to do this) then you could do something like this; # Function to check and install missing packages install_if_missing <- function(pkg) { if (!require(pkg, character.only = TRUE)) { install.packages(pkg, dependencies = TRU