[R] How to align group based on the common values of two columns in r

arun smartpink111 at yahoo.com
Tue Jan 22 19:58:08 CET 2013

You could also try:

 Feature    OS
    4              2
    4              1
    4              3
    1              2
    4              1
 dat1$Group<- as.numeric(factor(Reduce(paste0,dat1)))

----- Original Message -----
From: Tammy Ma <metal_licaling at live.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Sent: Tuesday, January 22, 2013 4:28 AM
Subject: [R] How to align group based on the common values of two columns in r


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,

    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
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