Is there a function to exit the current R script, but not exit the whole execution?
I mean, in a situation like this:
for (i in ...) { 
    ...
    source("model.R")
}
In file model.R, I need an exit function that would end the exection of the model.R:
...
exit 
...
So stop and stopifnot are out of question...
Seems that by far the easiest solution is to wrap the whole code in the sourced script into a loop and then break from it:
model.R (sourced script):
repeat {
...
break # this will exit the sourced script
...
break # just to prevent infinite loop in case the above break is removed
}
Thanks Joshua Ulrich for inspiration (he proposed to use a function).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With