0

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  
2
  • 1
    Does the answer on this question helps? stackoverflow.com/questions/1174799/… Commented Jul 24, 2015 at 14:13
  • @WannesRosiers - yes, it's helpful thank you. but I'm not yet understanding how I can add the source() command to the function to have it cycle through all 15 with a 60 second pause between each. Commented Jul 24, 2015 at 15:28

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah ha - that makes sense now, thank you for clarifying...but the cup of coffee I had helped too :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.