[R] Establishing groups using something other than ifelse()

2012-01-19 Thread Sam Albers
Hello all, This is one of those Is there a better way to do this questions. Say I have a dataframe (df) with a grouping variable (z). This is my base data. Now I know that there is a higher order level of grouping that exist for my group variable. So what I want to do is create a new column that

Re: [R] Establishing groups using something other than ifelse()

2012-01-19 Thread Justin Haynes
how bout levels(df$z)[grep('A',levels(df$z))] - 'A' levels(df$z)[grep('B',levels(df$z))] - 'B' levels(df$z)[grep('C',levels(df$z))] - 'C' does that do what you're wanting? On Thu, Jan 19, 2012 at 3:05 PM, Sam Albers tonightstheni...@gmail.comwrote: Hello all, This is one of those Is there

Re: [R] Establishing groups using something other than ifelse()

2012-01-19 Thread Sam Albers
On Thu, Jan 19, 2012 at 3:34 PM, Justin Haynes jto...@gmail.com wrote: how bout levels(df$z)[grep('A',levels(df$z))] - 'A' levels(df$z)[grep('B',levels(df$z))] - 'B' levels(df$z)[grep('C',levels(df$z))] - 'C' does that do what you're wanting? Shoot. Might have made my example confusing,

Re: [R] Establishing groups using something other than ifelse()

2012-01-19 Thread Jorge I Velez
Hi Sam, Check the examples in require(car) ?recode HTH, Jorge.- On Thu, Jan 19, 2012 at 6:05 PM, Sam Albers wrote: Hello all, This is one of those Is there a better way to do this questions. Say I have a dataframe (df) with a grouping variable (z). This is my base data. Now I know that

Re: [R] Establishing groups using something other than ifelse()

2012-01-19 Thread Sam Albers
That is great Jorge. Thanks! Just to complete this, I will include using record with this example: df$Big.Group2 - recode(df$z, c('G1','G2')='A'; c('H1','H2')='B'; else='C') Sam On Thu, Jan 19, 2012 at 3:49 PM, Jorge I Velez jorgeivanve...@gmail.com wrote: Hi Sam,

Re: [R] Establishing groups using something other than ifelse()

2012-01-19 Thread Duncan Murdoch
On 12-01-19 6:05 PM, Sam Albers wrote: Hello all, This is one of those Is there a better way to do this questions. Say I have a dataframe (df) with a grouping variable (z). This is my base data. Now I know that there is a higher order level of grouping that exist for my group variable. So what