function.Rd currently has no example of "stop", Similarly in Control.Rd, there
is currently no example of break: these might be helpful for users.
function.Rd suggestion:
# Often it is useful to be able to exit a function on some condition: Use
"stop" to do this
testJunk <- function(junk) {
if( is.null(junk)) {
stop("Junk must not be null!")
}
}
junk=NULL
testJunk(junk)
Control.Rd suggestion:
# Example using break: prints n unless n^2 exceeds 9: in which case it exits
the loop.
for(n in 1:5) {
if(n^2>9){
break
} else {
cat(n,"\n")
}
}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel