Re: [R] New-user support package - suggestions?

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu 04 May 2006 - 23:09:44 EST

I started on such a project a while ago for my personal use when creating packages. Often I forget to use na.rm and never test my functions with code containing missing values, and then later on have to search back through my code and ensure I've used na.rm=TRUE everywhere.

I didn't get very far, because at that point my code was segfaulting R on the mac. I've just re-looked at my code and it seems to run ok now. This might at least get you started:

trace_all <- function(fs, tracer) {

	sapply(fs, trace, tracer=tracer, print=FALSE)
	return()

}

functions_with_arg <- function(arg, pos) {

	fs <- ls(pos=pos)
	present <- unlist(lapply(fs, function(x) is.function(get(x)) && 
!is.null(formals(x)[[arg]])))         

        fs[present]
}

#trace_all(list("sum"), quote(if (!na.rm) warning("na.rm = FALSE")))

#trace_all(functions_with_arg("na.rm", "package:base"), quote(if (!na.rm) warning("na.rm = FALSE")))

Other functionality I'd like to see in such a package (from my needs as a developer) would be:

But they should take about 15 minutes to implement, so I'm not sure what you'd do for the rest of the 6 weeks.

Hadley



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 04 23:15:27 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 05 May 2006 - 00:10:11 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.