I have a .bat file as follows. task.bat
@echo off
R CMD BATCH C:\Users\Raghavan\Desktop\MyTask.R
The file needs to run an R script. The following is the R script.
A<-read.csv("C:\Users\Raghavan\Desktop\A.csv")
write.csv(A, file = "B.csv")
The R script runs by itself. However, when I try running it through the .bat file or through windows scheduler, the script fails to run. I have tried many sites.I request someoen to see if this error can be fixed. Most likely, the error is in the .bat file
@echo off
, a linecd C:\wherever\the directory\containing\the r executable\is located
to change the current directory whenR
is run. Replace the directory name with wherever the directory is from which you normally run R.