Re: [R] vectorized way to combine levels of a factor

2008-04-09 Thread Abhijit Dasgupta
For your first problem, you can probably do it in 2 statements: V3 = ifelse(V2==A,V2,V3) V3 = ifelse(V2==B|V2==C,D,V3) If you want to split V1 into (0,a],(a,b],(b,c],(c,1], you can do, quite simply V1.factor = cut(V1, c(0,a,b,c,1)) Abhijit On Wed, 9 Apr 2008 13:58:17 -0700 Chang Liu <[EMAIL PROTE

[R] vectorized way to combine levels of a factor

2008-04-09 Thread Chang Liu
Hi Gurus: If I have a large dataset of the form of: > x <- data.frame(V1 = runif(10), V2 = sample(c('A','B','C'),10,T)) > x > V1 V21 0.2691580 A2 0.8711267 B3 0.2674728 C4 0.3278876 A5 > 0.1809152 A6 0.2499651 C7 0.9155174 A8 0.8004974 B9 0.7885516 A10 > 0.9301630