Re: [R] replace funcion

2012-08-11 Thread David L Carlson
--- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of arun > Sent: Saturday, August 11, 2012 5:17 PM

Re: [R] replace funcion

2012-08-11 Thread arun
HI, Try this: set.seed(1)  df1<-data.frame(colA=sample(1:100,n,replace=TRUE)) numbers1<-c(1,2,3,4,11,12)  numbers2<-c(5,6,7,8,9,10)  df1$colA[df1$colA%in%numbers1]<-"invierno"  df1$colA[df1$colA%in%numbers2]<-"verano"  head(df1,10) colA 1  27 2  38 3  58 4  91 5  21 6   

Re: [R] replace funcion

2012-08-11 Thread arun
HI, I guess this should also work. set.seed(1)  df1<-data.frame(colA=sample(1:100,n,replace=TRUE)) numbers1<-c(1,2,3,4,11,12)  numbers2<-c(5,6,7,8,9,10) df1[df1$colA%in%numbers1,]<-"invierno" df1[df1$colA%in%numbers2,]<-"verano" #or set.seed(1)  df1<-data.frame(colA=sample(1:100,n,replace=TRUE))

Re: [R] replace funcion

2012-08-11 Thread Rui Barradas
Hello, Try the following, using index vectors, not recode(). inx <- datos.mx1[, 7] %in% 5:10 datos.mx1[inx, 7] <- "verano" datos.mx1[!inx, 7] <- "invierno" Hope this helps, Rui Barradas Em 11-08-2012 20:10, Dominic Roye escreveu: Hello everybody, I would like to replace or recode a list of