[R] Documenting a function: How to get the comments in a function similar to args()

Carl Witthoft carl at witthoft.com
Fri Aug 15 23:40:43 CEST 2008


Along the lines of Gabor's method, presumably you could put a "spare" 
argument in your function:


foo<- function(x,help=FALSE,...)
{
helpout<-c(comment,
comment,
end of comments)
if(something_is_wrong_with_inputs || help=TRUE)
	{
	print(helpout)
	stop #or trycatch, or whatever you prefer
	}
[remainder of function]
}

I know that's sloppy but I'm new to R.

Carl



More information about the R-help mailing list