Task scheduler not working in R Studio

Hello,
Please I am trying to schedule a simple R script, with the below code:

rawData <- rnorm(10000)
hist(rawData,
     col = "lightblue",
     main = "Histogram of Random Data")

The script is called histogram.R. I wrote a schedule for it to run every 5 minutes with the taskscheduleR package. Here is the schedule code below:

library(taskscheduleR)
hscript <- "C:/Users/IFEANYI/Documents/RData/histogram.R"

run_script <- taskscheduler_create(
  taskname = "Histogram",
  rscript = hscript,
  schedule = "MINUTE",
  starttime = format(Sys.time() + 60, "%H:%M"),
  modifier = 5
)

After setting the schedule, I got a message saying my schedule was set successfully. Nevertheless, the script doesn't run on schedule. It doesn't run at all. I kept R Studio open, hoping to see the shape of the histogram plot change every 5 minutes, but nothing is happening. Please can someone advise me on what is going on, or what I am not doing right? Thanks as always for your help.

1 Like

Alter your script to save histogram output to a file(s) you can check. Your code is running and a histogram is plotted to an r session you can't see.
If you wanted a live window with changing plot, shiny app would be an option, otherwise, decide on a definite output for your script and schedule it , and then monitor your outputs.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.