0

I am trying to use the R's taskscheduleR package to download data using a script every tenth of a minute (every 6 seconds). To do this, I have a script named getwmatadata.R which downloads data from an API and I am trying to call this script using taskscheduleR based on the following link: https://github.com/bnosac/taskscheduleR

However, my script below is not working because I get an error saying

Error in taskscheduler_create(taskname = "wmatadata", rscript = wmatapinger, : File does not exist

Below is how I'm trying to run taskscheduleR:

library(taskscheduleR)
wmatapinger <- system.file("extdata", "getwmatadata.R", package = "taskscheduleR")
taskscheduler_create(taskname = "wmatadata", rscript = wmatapinger, schedule = "MINUTE", starttime = "05:00", modifier = 0.1)
TylerH
  • 20,799
  • 66
  • 75
  • 101
Gaurav Bansal
  • 5,221
  • 14
  • 45
  • 91

4 Answers4

2

Just configure the path to your script using file.path() ... don't use system.file()

Solution:

wmatapinger <- file.path("C:", "name_of_the_folder", "wmatapinger.R")

Please refer to the file.path() how to construct the path (comma means forward slash / )

Your next line is fine and now it should work.

Maximilian
  • 4,177
  • 7
  • 46
  • 85
1

I was getting the same error. Although it took several attempts (I kept getting the error "file does not exist"), I was finally able to solve it by scheduling it via the GUI add-in.

If you're using RStudio, go to Tools → Addins → "Schedule R scripts on…". This eventually worked for me.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
1

Check if your .R file exist on the path that you specified.

file.exists(wmatapinger)
-1

One possible solution and easy to implement -

library(taskschedulerR)
taskscheduler_create(taskname = "ABC",
                     rscript = Full Address of the 
                               script, 
                     schedule = "DAILY", 
                     starttime = "23:45", 
                     startdate = format(Sys.Date(), 
                                        "%d/%m/%Y"))
Raj
  • 3,637
  • 8
  • 29
  • 52
Ganesh S
  • 102
  • 11