Reputation: 1712
I would like to write an R script that runs for the whole day. It should basically be an infinite loop that fetches trading data, applies smart stuff to it, and uploads the trading data somewhere else again.
I'm thinking about starting the script at 8:30am, then it would automatically "do nothing" until 9:00am, then start running in a loop until 5:00pm, and then idle again, until I shut down the R session.
What's the best way to achieve this behavior?
I have no access to Linux machines, so multiple scripts and cronjobs are not possible, unfortunately.
Upvotes: 1
Views: 464
Reputation: 189
while ( as.numeric(format(Sys.time(),format = "%H")) %in% 8:17){
if(as.numeric(format(Sys.time(),format = "%H")) %in% 9:17){
# your code here
}
}
Upvotes: 2
Reputation: 937
You can take a look at this link
Windows Task scheduler can do the task
Even with Rstudio you can
Some more links here and here Link
Then the package taskschedulR
Upvotes: 2
Reputation: 173
If you're on a Windows consumer platform, you could use the 'scheduleR' package. Otherwise, if you're on a Windows Server, then you could use the Windows Scheduler.
Upvotes: 1