简体   繁体   中英

Checking installed version of R package and update if old

We are managing the R packages in cluster via puppet and we have created one file which has commands like below. We have mirror of R package repo internally.

install.packages("BH",repos=NULL, dependencies=TRUE, contriburl= http://our_internal_repo.com )

in the rPackages.xt

This using puppet we are executing via RScript rPackages.txt

Now in next week we get 3 more additional packages , we modify the rPackages to include additional lines for new packages.

Now since scirpt will read from start to end , it will try to reinstall all packages.

My question is , how to install package only if the version installed is not same as the one present in our internal repo.

How to do those checks in the RScript and execute puppet accordingly.

What are the best practices to manage R installations.

Thanks

Change the Rscript to

if("BH" %in% rownames(installed.packages()) == FALSE) {install.packages("BH")}

as for the version, you could probably use packageVersion somehow.

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