[Rd] often unnecessary duplicate in sapply / as.vector

Martin Morgan mtmorgan at fhcrc.org
Fri Jul 7 14:37:32 CEST 2006

sapply calls lapply as

    answer <- lapply(as.list(X), FUN, ...)

which, when X is a list, causes X to be duplicated unnecessarily. The
coercion is unnecessary for other mode(X) because in lapply we have

    if (!is.list(X)) X <- as.list(X)

More generally, perhaps as.vector might not duplicate when mode(x) == mode ?


R version 2.4.0 Under development (unstable) (2006-07-05 r38495) 


attached base packages:
[1] "tools"     "methods"   "stats"     "graphics"  "grDevices" "utils"    
[7] "datasets"  "base"

More information about the R-devel mailing list