[R] Seg fault with trace

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Dec 27 09:41:11 CET 2005

hadley wickham wrote:
> (Under 2.2.0, Mac)
> I have been unable to reduce this to a simple case, so I'll include my
> full code, and my intentions.  The problem I'm trying to solve is that
> while many defaults (eg. na.rm=F, drop=T) make sense for interactive
> programming, they tend to be a bit of a pain when developing a
> package.  For example, I often forget to use drop=FALSE, only test
> with multiple columns and then spend ages trying to figure out why it
> doesn't work when I use the function with a single column. The idea of
> the functions below is to automatically warn me when I do something
> like that.
> 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")))
> # Works
> trace_all(functions_with_arg("na.rm", "package:base"), quote(if
> (!na.rm) warning("na.rm = FALSE")))
> # Segfaults
> I'd be happy to explore alternative approaches, especially since this
> approach modifies the functions in their original namespaces, and I
> only want to see the warnings when my functions use these functions.

Does not segfault for me with R-2.2.1, neither on Windows nor on Linux.
For any follow-ups I recommend to use the R-devel list for this kind of 
function and probable segfault problems.

Uwe Ligges

> Hadley
> ______________________________________________
> R-help at 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

More information about the R-help mailing list