[R] Sorting / editing a table

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Jul 10 12:34:05 CEST 2008


Jörg Groß wrote:
> Hi,
>
> I have a problem sorting a table;
>
> When I read a table into R by x <- read.table() I get something like
> this:
>
> V1    V2    V3
> yes    1    3
> no    2    6
> yes    3    9
> no    4    12
>
> Now I want to generate a vector of V2.
> But R should only put in the numbers of V2 into the new vector when
> there is the entry "yes" in V1.
>
> How can I realize that?
>

x[x$V1=="yes","V2"]

vQ



More information about the R-help mailing list