Home > Mobile >  Executing multiple source files in sequence using R
Executing multiple source files in sequence using R

Time:11-26

I have multiple source files in R which I want to execute daily in sequence using one cron job.

The code looks like -

Master_script.R
...
...
tryCatch({
source(abc.R)
source(pqr.R)
source(xyz.R)
}, error=function(e) {
    print(e)})
...
...

In case there is an error in abc.R, an error is thrown and the rest of the Master_script.R is not executed. However, I want to execute the rest of the R files pqr.R and xyz.R incase abc.R fails.

In case there is an error in abc.R, is there a way to skip file abc.R, and continue executing the remaining source files?

FYI... I am not considering packing things up into a R package for now. Also, I don't want to create separate cron jobs.

CodePudding user response:

I use tryCatch to avoid the Shinyapp crashing when encountering an error. See if this works. Good luck.

tryCatch(error = function(err) {return(error_value)}, source(abc.R) )

  •  Tags:  
  • r
  • Related