I need to build a reproducible R installation from the command line. Seems easy enough, so I created a file with my package names of interest, for example
packages.txt:
ggvis
glmnet
caret
The an R script called installPkgs.R:
f = read.csv('packages.txt', header=FALSE)
z = install.packages(f[,1], repos='https://cran.rstudio.com')
And then I should be able to run this from the command line:
Rscript installPkgs.R
When I do, the packages are downloaded but not installed. What am I missing?
Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.
To install any package from CRAN, you use install. packages() . You only need to install packages the first time you use R (or after updating to a new version). **R Tip:** You can just type this into the command line of R to install each package.
Answering my own question so that the answer is obvious and not buried into the coimments.
In my code, the list of packages is being interpreted as a factor rather than character strings. So, I need to set the parameter in read.csv() or the global parameter stringsAsFactors = FALSE.
Urgh.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With