bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
331 stars 72 forks source link

Running a script part of Rstudio Project and has spaces in its location #74

Closed msgoussi closed 4 years ago

msgoussi commented 4 years ago

Dear Mr. Jan, I am trying to use your package, but I failed to run the script because of two things 1) the location of file has spaces, I can not edit the folder location because I do not have admin rights (i am using windows) 2) how to run a script part of Rstudio Project I have tried reading https://community.rstudio.com/t/how-to-play-nice-with-taskscheduler-r-studio-projects-and-here/24406 but i could not get it properly.

Please advise, with example.

jwijffels commented 4 years ago

Please provide reproducible examples. Statements like 'it does not work' will not get you any further

msgoussi commented 4 years ago

I have script called Trial.R inside RStudio Project setwd(rstudioapi::getActiveProject()) source("0. Sources.R") # Another important script inside the Project i can not drop it. setwd("D:\temp") download.file("https://www.imf.org/external/pubs/ft/weo/2019/02/weodata/WEOOct2019all.xls", "x.xls", mode = "wb")

rest of the code

When I use taskscheduleR, it copies Trial.R into D:\R\R-3.6.3\library\taskscheduleR\extdata and file x.xls has not been downloaded in temp folder.

jwijffels commented 4 years ago

So where does the scheduling fail?

msgoussi commented 4 years ago

The file is not downloaded at all.

jwijffels commented 4 years ago

So the problem is not related to the taskscheduleR package which does the scheduling but in your own R script. Why do you think calls to rstudioapi::getActiveProject() will work if your script is not run in RStudio? Please change all your setwd calls to right paths which exist on your hard drive and where you have access rights to and learn how to work with environment variables. Same question as https://github.com/bnosac/taskscheduleR/issues/60 Closing.