Hello,

I am trying to run an R script that is executed using an "R CMD BATCH" command in the command prompt. I first tried using the "install.packages" command at the beginning of my script but it failed because it could not select a CRAN mirror. I changed this to install.packages('Package Name', repos='http://cran.us.r-project.org') and then library(Package Name). Sometimes my code works fine but other times my .Rout file provides an error such as this: 

Warning message:

In library(package, lib.loc = lib.loc character.only=TRUE logical.return=TRUE, :     there is no package called 'plyr')

It also tends to fail with the foreign and reshape packages. How can I install packages via R script so it does not fail? My current code appears below:

install.packages('reshape', repos='http://cran.us.r-project.org')

install.packages('foreign', repos='http://cran.us.r-project.org')

install.packages('plyr', repos='http://cran.us.r-project.org')

install.packages('dplyr', repos='http://cran.us.r-project.org')

install.packages('doBy', repos='http://cran.us.r-project.org')

require(reshape)

require(foreign)

require(plyr)

require(doBy)

require(dplyr)

Thanks!

Similar questions and discussions