简体   繁体   中英

Getting dependencies error while installing R packages in Ubuntu Using pacman

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM