Henrik Bengtsson
2006-Mar-14 12:40 UTC
[Rd] Can example() code stop the example without generating an error?
Hi,
does anyone know if it is possible to write example code (in Rd
examples) such that one can stop the example without generating an
error? Example:
code A
if (cond)
niceStop()
code B
I know this sounds weird, but I would like some of my Rd examples to
run if and only if another package is available or if a certain large
Affymetrix data file is available. One can put all of the example in
a function and return from the function if the package is not
available, but then all object assigned are lost. My best/cleanest
solution right now is to use break in a dummy for loop. Examples:
for (z in 1) {
code A
if (cond)
break
code B
}
Other suggestions? The solution must off course pass R CMD check.
/Henrik
PS. I know example() calls source(), but I'm not sure how R CMD check
does it. DS.
Uwe Ligges
2006-Mar-14 13:01 UTC
[Rd] Can example() code stop the example without generating an error?
Henrik Bengtsson wrote:> Hi, > > does anyone know if it is possible to write example code (in Rd > examples) such that one can stop the example without generating an > error? Example: > > code A > if (cond) > niceStop() > code BWhat about code A if(cond){ code B } But maybe I do not get your point. Uwe Ligges> I know this sounds weird, but I would like some of my Rd examples to > run if and only if another package is available or if a certain large > Affymetrix data file is available. One can put all of the example in > a function and return from the function if the package is not > available, but then all object assigned are lost. My best/cleanest > solution right now is to use break in a dummy for loop. Examples: > > for (z in 1) { > > code A > if (cond) > break > code B > > } > > Other suggestions? The solution must off course pass R CMD check. > > /Henrik > > PS. I know example() calls source(), but I'm not sure how R CMD check > does it. DS. > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Maybe Matching Threads
- New simpleExit() condition (Was: Re: Can example() code stop the example without generating an error?)
- Could not install aroma.affymetrix
- Make scripts during package installation?
- [LLVMdev] Instructions that cannot be duplicated
- SweaveInput and absolute paths