Reputation: 696
Is there a way in R to pause execution of a script until a file is created? I would like to pre-load R in advance to decrease the execution time when the input file is generated.
Upvotes: 7
Views: 4456
Reputation: 44340
If you want to keep this in R, you might try the following code:
while (!file.exists(your.file.name)) {
Sys.sleep(1)
}
A shorter sleep duration would poll more frequently but might be slightly more CPU intensive.
Upvotes: 12