Re: [R] Reassign Multiple Factors to same Factor Value

2013-03-25 Thread arun
Hi, You could also try: library(plyr) df1<- df df2<- df  df$y<-revalue(df$y,c("e"="others","f"="others","g"="others")) df$y #[1] a  b  c  d  others others others #or df1$y<-mapvalues(df1$y,from=c("e","f","g"),to=rep("others",3)) levels(df1$y) #[1] "a"  "b"  "c"  "d" 

Re: [R] Reassign Multiple Factors to same Factor Value

2013-03-25 Thread soon yi
or just levels(df$y)[5:7]<-"others" Ista Zahn wrote > Hi Lorenzo, > > On Mon, Mar 25, 2013 at 6:18 PM, Lorenzo Isella > < > lorenzo.isella@ > > wrote: >> Dear All, >> Probably something very easy, but I am looking for the most efficient >> ways >> to achieve this. >> Consider the following sn

Re: [R] Reassign Multiple Factors to same Factor Value

2013-03-25 Thread Ista Zahn
Hi Lorenzo, On Mon, Mar 25, 2013 at 6:18 PM, Lorenzo Isella wrote: > Dear All, > Probably something very easy, but I am looking for the most efficient ways > to achieve this. > Consider the following snippet > > y<-c('a','b','c','d','e','f','g') > x<-rnorm(length(y)) > df<-data.frame(y,x) > > lea