From timothy.c.bates at gmail.com  Sat Aug  6 19:29:16 2011
From: timothy.c.bates at gmail.com (Timothy Bates)
Date: Sat, 6 Aug 2011 18:29:16 +0100
Subject: [Rd] adding examples of stop and break to function.Rd and Control.Rd
Message-ID: <6A05ACD3-86AA-4EDF-BB9E-57FF0BAE7C95@gmail.com>

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")
   }
}



[Rd] adding examples of stop and break to function.Rd and Control.Rd
Timothy Bates