10

I have been trying to execute a simple test.R

setwd("C:\Users\jdd\Documents")
test <- 2*6598
filename = "test.csv"
write.csv(test,file=filename)

Via the following command line command in Windows:

"C:\Program Files\R\R-2.15.2\bin\R.exe" CMD BATCH   --vanilla --slave "C:\Users\jdd\Documents\test.R"

When I execute this I get the following error:

The system cannot find the path specified.

I have been trying to work out a solution on the basis of the provided error message, but failed so far. Wondering if somebody can help me so I can execute the script directly from the command line. Thanks

4
  • You sure? R should throw an error about \U being used without hex digits on that setwd line. Commented Feb 19, 2013 at 11:57
  • 3
    Use setwd("C:\\Users\\jdd\\Documents") or setwd("C:/Users/jdd/Documents"). Commented Feb 19, 2013 at 11:58
  • Thanks for the comments. Removed setwd() line and still receive the same error. Commented Feb 19, 2013 at 12:05
  • 1
    @Jochem Have you considered using Rscript? I don't think R CMD BATCH is recommended anymore. Do you get "no input file" for "C:\Program Files\R\R-2.15.2\bin\R.exe" CMD BATCH on its own? Commented Feb 19, 2013 at 12:08

2 Answers 2

15

Thanks @sebastian-c! I tried to use RScript, which I investigated before. However, the problem was a different one. Appears that in my installation there is a R.exe and Rscript.exe file in .\bin, but also one in .\bin\x64. The first one is not working properly, but the second one is. The comment made by @Roland is very important as well, since once working I got this error message!

The following command did the job:

"C:\Program Files\R\R-2.15.2\bin\x64\Rscript.exe" "C:\Users\jdd\Documents\test.R"

and the corrected text.R is:

setwd("C:\\Users\\jdd\\Documents")
test <- 2*6598
filename = "test.csv"
write.csv(test,file=filename)
Sign up to request clarification or add additional context in comments.

Comments

4

As mentioned here, it might has something to do with 64bit version of R. The problem is that Rscript.exe itself is attempting to access a missing file on the system. The obvious fix is explicitly add 'x64' to the path of the other Rscript.exe that was installed:

"C:\Program Files\R\R-2.15.2\bin\x64\Rscript.exe" --version
R scripting front-end version 3.0.2 (2013-09-25)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.