[R] subset, once more
RenE J.V. Bertin
rjvbertin at hotmail.com
Mon Jul 8 18:39:58 CEST 2002
New to R, I had the bad idea to send a bug report about '[' not knowing it
had a drop= argument. Now, I wonder about the absence of this argument in
subset...
In both availabe methods (see below), there is a ... argument, but this
argument is not used in either. Rather, subset.data.frame explitictly passes
drop=F in 1 instance.
Before I start patching (for my own use): what is the reason for this?
>subset.default
function (x, subset, ...)
x[subset & !is.na(subset)]
>subset.data.frame
function (x, subset, select, ...)
{
if (missing(subset))
r <- TRUE
else {
e <- substitute(subset)
r <- eval(e, x, parent.frame())
r <- r & !is.na(r)
}
if (missing(select))
vars <- TRUE
else {
nl <- as.list(1:ncol(x))
names(nl) <- names(x)
vars <- eval(substitute(select), nl, parent.frame())
}
x[r, vars, drop = FALSE]
}
RenE J.V. Bertin
College de France/LPPA
11, place Marcelin Berthelot
75005 Paris, France
_________________________________________________________________
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list