When working in R projects, my workspace is usualy organized with several R child-files sourced by a centralized mother-file.
Basically this looks like:
mother.r
print("Go")
source("child1.r")
print("Step 1 OK")
source("child2.r")
print("Step 2 OK")
child1.r and child2.r
print("child1.r, starting")
doSomething()
doSomethingElse()
everythingIsFine = TRUE
stopifnot(everythingIsFine)
#testing
doSomeVerifications()
With this, I can source mother.r
to have my study regenerated after some modifications, which will print a report.
The point is that the end of my childX.r
is full of code that can be useful for some testings, but should not be sourced by mother.r
. But if I use stop()
before doSomeVerifications()
, the mother sourcing will stop too.
How can I stop the sourcing just before the verifications ?