[R] How to align group based on the common values of two columnsinr
Gerrit Eichner
Gerrit.Eichner at math.uni-giessen.de
Tue Jan 22 10:38:42 CET 2013
Hi, Tammy,
maybe you find something interesting looking at
?interaction
and/or try (with df being your data frame)
df$Group <- as.integer( with( df, interaction( Feature, OS)[, drop =
TRUE]))
HtH -- Gerrit
On Tue, 22 Jan 2013, Tammy Ma wrote:
>
> HI,
>
> I met this problem:
>
> I have the feature data frame:
>
>
> Feature OS
> 4 2
> 4 1
> 4 3
> 1 2
> 4 1
>
>
> what I want to do is to autimatically create one more column called "group":
>
> Feature OS Group
> 4 2 1
> 4 1 2
> 4 3 3
> 1 2 4
> 4 1 2
>
>
>
> I don't want "Ifelse", because I have so many combination of feature and OS, I even can not account. I just want to have sth to autimatically create group indicator based on the difference combination of feature and OS.
>
> Thanks for your help.
>
>
> Kind regards,
> Tammy
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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