Re: [R] Seg fault with trace

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 27 Dec 2005 - 19:41:11 EST

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@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



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 Tue Dec 27 19:47:11 2005

This archive was generated by hypermail 2.1.8 : Tue 27 Dec 2005 - 23:53:54 EST