Reputation: 333
I'm trying to source multiple R scripts with a short delay in between each one. The 15 R scripts to be 'sourced' all collect data from GA API, transform/clean/analyze the data, then finally push the into their own worksheets within a single Google Sheet. So I'd like to set a wait of 1 minute between each script to make sure I'm not overloading the Google Sheet file.
How can I turn the code (below) into a mini-function where there is a wait time between each source()
command?
source("/code/processed/script1.R")
source("/code/processed/script1.R")
source("/code/processed/script1.R")
...
source("/code/processed/script15.R")
Thanks in advance for your help! :)
PS - For context, please note I have my working directory organized in the following hierarchy:
|-project
|-code
|-processed
|-raw
|-data
|-processed
|-raw
Upvotes: 0
Views: 324
Reputation: 1690
As suggested in my comment I would use sys.sleep(), either by manually adding it netwerk every source command:
source(...)
sys.sleep(60)
source(...)
Or by storing all scripts in a vector and looping over them.
Upvotes: 1