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

From: Benjamin Tyner <btyner_at_gmail.com>
Date: Wed, 22 Jun 2011 21:55:04 -0400


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


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 23 Jun 2011 - 03:08:17 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 23 Jun 2011 - 11:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive