0

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.

2
  • try adding tryCatch in those scripts or have break Commented Nov 25, 2021 at 20:44
  • Something like following for each file? tryCatch({ source(abc.R) }, error=function(e) {print(e)} Commented Nov 25, 2021 at 20:48

1 Answer 1

1

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) )

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.