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
"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.
...
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
3 matches
Mail list logo