Reputation: 51
I am using pacman
to install and load the mentioned libraries. But it is throwing a dependency error and lock error in installing caret
.
My main motive to use this library was to auto detect the libraries in R so that if present, load the library else install and load.
pacman::p_load(dplyr,caret,plyr)
was the code that I used.
Upvotes: 1
Views: 1497
Reputation: 1095
The dependency error may be due to pacman::p_load()
default behaviour being not to update packages that already exist in your r library.
Thus, if in this example, you are trying to install caret
(which you don't have in your library) and it has a dependency Rcpp
(which is already in your library because it is also a dependency for several other packages that you have already installed, or you installed it separately previously), pacman::p_load()
will install caret
and not update Rcpp
.
This may then generate a conflict if the latest version of caret
also depends on the latest version of Rcpp
, but you have an old version of Rcpp
.
Instead, you can change the update
argument to TRUE
:
# Check for, install (if necessary) and load packages:
pacman::p_load(dplyr, caret, plyr, update = TRUE)
This may not be a sufficiently targeted solution, because it will update the desired packages AND their dependencies, whereas ideally it would be better if only dependencies that failed to meet the minimum required version number for the desired packages are updated.
Upvotes: 0
Reputation: 51
install.packages("Rcpp", dependencies = TRUE, INSTALL_opts = '--no-lock')
In place of Rcpp you can pass a variable which will change according to your iterations for every record on the list having the names of libraries to be downloaded. It solved my issue.
Upvotes: 1