Skip to content
Prev 31326 / 63424 Next

Bug in subsetting data frame (PR#13515)

On Tue, 10 Feb 2009 xinlee883 at stat.math.ethz.ch wrote:

            
These are not bugs.
This can't possibly work, since you have explicitly requested that subset not be a data frame.

There has been recent discussion about whether row names should be added as names to vectors from a data frame, in which case subset['a'] would then work. It doesn't now, and that isn't a bug either.
This is also not a bug.  The drop= option to [ controls what happens when the subset has dimensions of length 1. If you want subset to be a data frame in this context, use
   subset <- data.frame[,'x',drop=FALSE]
and then subset['a',] will do want you want.

        -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle