[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 ?
Martin
R version 2.4.0 Under development (unstable) (2006-07-05 r38495)
x86_64-unknown-linux-gnu
locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C
attached base packages:
[1] "tools" "methods" "stats" "graphics" "grDevices" "utils"
[7] "datasets" "base"
More information about the R-devel
mailing list