[R] subset with two factors

Michael Bedward michael.bedward at gmail.com
Fri Dec 10 12:35:56 CET 2010


Hello Martin,

You were almost there :)

T1 <- subset(daten1, Geschlecht=="M" & GG=="A")

Hope this helps.

Michael

On 10 December 2010 22:25, Martin Spindler <Martin.Spindler at gmx.de> wrote:
> Dear all,
>
> I have a dataframe of the following strucutre
>
>  numacc_b coverage_b Geschlecht GG
> 1        0          1          W  A
> 2        0          1          M  A
> 3        0          1          M  B
> 4        0          1          M  B
> 5        0          1          W  A
> 6        0          1          M  B
>
> I would like to form a subset consisting of all entries with Geschlecht=M and GG=A.
>
> Using
>
>>T1 <- subset(daten1, Geschlecht=="M", GG=="A")
>
> delievers
>
> data frame with 0 columns and 6 rows
>
>> T1 <- subset(daten1, Geschlecht=="M")
>
> delievers
>
>  numacc_b coverage_b Geschlecht GG
> 2         0          1          M  A
> 3         0          1          M  B
> 4         0          1          M  B
> 6         0          1          M  B
> 9         0          1          M  B
> 10        0          1          M  B
>
> But I want to select the dataframe according to both factos.
>
> What can I do?
>
> Thank you answers in advance!
>
> Best,
>
> Martin
> --
> GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit
> gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list