[R] data.frame: how to extract parts

(Ted Harding) Ted.Harding at manchester.ac.uk
Sat Jan 17 10:48:47 CET 2009


On 17-Jan-09 02:57:13, Jörg Groß wrote:
> Hi,
> I have a problem with the R syntax.
> It's perhaps pretty simple, but I don't understand it ...
> 
> I can extract a column from a data.frame with the following code
> for example ...
> 
> b$row1[b$row1 == "male"]
> 
> so I see all male-entries.
> 
> But I cannot extract all lines of a data.frame depending on this  
> criterium;
> 
> only.male <- b[b$row1 == "male"]
> 
> With that, I get an "undefined columns selected" message.
> 
> So how can I extract lines of a data.frame depending on a level  
> variable?

  only.male <- b[b$row1 == "male",]

should work.
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 17-Jan-09                                       Time: 09:48:43
------------------------------ XFMail ------------------------------




More information about the R-help mailing list