Timothy Bates
2011-Aug-06 17:29 UTC
[Rd] adding examples of stop and break to function.Rd and Control.Rd
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") } }