From btyner at gmail.com  Thu Jun 23 03:55:04 2011
From: btyner at gmail.com (Benjamin Tyner)
Date: Wed, 22 Jun 2011 21:55:04 -0400
Subject: [Rd] suggestion for subset.data.frame()
Message-ID: <4E029CF8.3000404@gmail.com>

Hello,

Currently, subset.data.frame() does

    if (missing(subset))
            r <- TRUE
        else {

perhaps better might be:

    if (missing(subset))
            r <- rep(TRUE, nrow(x))
        else {

The rationale being, if 'x' has zero rows and 'subset' is missing, we 
don't want to end up with more rows than we started with:

     > subset(head(iris, 0), select = -Species)
       Sepal.Length Sepal.Width Petal.Length Petal.Width
    NA           NA          NA           NA          NA

Thoughts?
-Ben


[Rd] suggestion for subset.data.frame()
Benjamin Tyner