[R] data.frame: how to extract parts

jim holtman jholtman at gmail.com
Sat Jan 17 04:19:19 CET 2009


You are missing a comma.  You are addressing the dataframe as if it
were a matrix and you want to extract all the rows that match:

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

On Fri, Jan 16, 2009 at 9:57 PM, Jörg Groß <joerg at licht-malerei.de> 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?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list