I've defined my own version of summary.default, that gives a better summary for highly skewed vectors.
If I call summary(x) the method is used. If I call summary(data.frame(x)) the method is not used. I've traced this to lapply; this uses the new method: lapply(list(x), function(x) summary(x)) and this does not: lapply(list(x), summary) If I make a copy of lapply, WITHOUT the environment, then the method is used. lapply <- function (X, FUN, ...) { FUN <- match.fun(FUN) if (!is.vector(X) || is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) } I'm curious to hear reactions to this. There is a March 2006 thread object size vs. file size in which Duncan Murdoch wrote: > Functions in R consist of 3 parts: the formals, the body, and the > environment. You can't remove any part, but you can change it. That is exactly what I want to do, remove the environment, so that when I define a better version of some function that the better version is used. Here's a function to automate the process: copyFunction <- function(Name){ # Copy a function, without its environment. # Name should be quoted # Return the copy file <- tempfile() on.exit(unlink(file)) dput(get(Name), file = file) f <- source(file)$value f } lapply <- copyFunction("lapply") [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.