Re: [R] Assigning cases to groupings based on the values of several variables

2012-12-07 Thread Duncan Murdoch
On 12-12-07 7:27 AM, Dimitri Liakhovitski wrote: Dear R-ers, my task is to simple: to assign cases to desired groupings based on the combined values on 2 variables. I can think of 3 methods of doing it. Method 1 seems to me pretty r-like, but it requires a lot of lines of code - onerous.

Re: [R] Assigning cases to groupings based on the values of several variables

2012-12-07 Thread Dimitri Liakhovitski
My example data indeed looks regular, but in reality neither the data nor the assignments are regular. E.g., sometimes all females would land in one grouping and males of different ages will land in different groupings. So, I am afraid the with solution won't work. Dimitri On Fri, Dec 7, 2012 at

Re: [R] Assigning cases to groupings based on the values of several variables

2012-12-07 Thread Dimitri Liakhovitski
Wow, Arun I think I really like this solution. It allows me to create irregular groupings and is very parsimonious. Thank you very much! Dimitri On Fri, Dec 7, 2012 at 8:09 AM, arun smartpink...@yahoo.com wrote: HI, In your method2 and method3, you are using the groupings data. If that is

Re: [R] Assigning cases to groupings based on the values of several variables

2012-12-07 Thread arun
HI, In your method2 and method3, you are using the groupings data.  If that is the case, is it possible for you to use ?merge() or ?join() from library(plyr)  join(mydata,groupings,by=c(sex,age),type=inner)  #  sex age mygroup #1    m   1   1 #2    m   2   2 #3    m   3   3 #4    m