1

I need help with that problem. Searching on Google, I've found a way to run the R script without error. It's creating a .bat file with the directorys of Rscript.exe and the script I want to run:

enter image description here

My script is very simple: create a dataframe and save it on a Excel.

library(xlsx)

employee <- c('John Doe','Peter Gynn','Jolie Hope')
salary <- c(21000, 23400, 26800)
startdate <- as.Date(c('2010-11-1','2008-3-25','2007-3-14'))

employ.data <- data.frame(employee, salary, startdate)

write.xlsx(employ.data, 'prueba_r_excel.xlsx')

print('final script')

When I manually run the file, it works without problems and creates the Excel:

enter image description here

enter image description here

But when I put it on task scheduler of windows,

enter image description here

enter image description here

it seems that it does the whole script without problems (it shows the print) but it doesn't create the file for me. Someone knows what could be the problem? Do I have to give some kind of special permission to creat new files from the task scheduler?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Franky1010
  • 11
  • 2

1 Answers1

0

First I thought that Task Scheduler could not create new files, because I saw that the Task Scheduler doesn't have write permissions. But later I found the error, and that is that in the part of the path where the file is saved you have to put it entire.

The problem was that if I ran the R script manually, the Excel is created in that same folder, but when executing it from the Task Scheduler I also created it but in another folder (system32)

TylerH
  • 20,799
  • 66
  • 75
  • 101
Franky1010
  • 11
  • 2