I am trying to run an R script through the command line. My R script contains statement for inclusion of library and some methods of the same library as given here. The command line statement I am using to run the code is as below.
Test.R
library("readxl")
sales <- read_xlsx("<file path>", sheet = 1)
Commands:
cd "C:\Users\Debasish.sena\Desktop\out"
"C:\Program Files\R\R-3.2.2\bin\x64\Rscript.exe" -e "install.packages('readxl', repos = 'https://cran.us.r-project.org')"
"C:\Program Files\R\R-3.2.2\bin\x64\R.exe" CMD BATCH "C:\Users\Debasish.sena\Documents\Test.R" "C:\Users\Debasish.sena\Desktop\out\Test.Rout"
While executing the command I am getting the error as below: Warning in install.packages("readxl", repos = "https://cran.us.r-project.org")
: 'lib = "C:/Program Files/R/R-3.2.2/library"' is not writable Error in install.packages("readxl", repos = "https://cran.us.r-project.org")
: unable to install packages Execution halted
I am expecting the R script to be executed and the results stored in 'sales' variable
I think you are not logged in as Administrator, or you are trying to install on a remote system. Can you print the result of .libPaths()
?
I had encountered a similar issue, I solved it as follows:
That's it,
I tested it on 64-bit windows 10 enterprise.
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.