Re: [R] Recode values

2013-11-22 Thread arun
Hi, May be this helps: set.seed(49) dat1 - as.data.frame(matrix(sample(c(NA,0:2),20,replace=TRUE),ncol=2)) dat2 - dat1  lst1 - list(letters[1:3],letters[26:24]) library(plyr)  dat1[] -lapply(seq_len(ncol(dat1)),function(i) {x1 -dat1[,i]; x2 - lst1[[i]]; mapvalues(x1,c(0,1,2),x2)}) #Or dat2[]

[R] Recode values

2013-11-22 Thread lillosdos
Hi I'm Pasquale, I need to recode variables (columns) of a dataframe (call it X). The observations (rows) are coded as numeric 0,1,2 and NA. I managed to use the lapply() function with recode() as FUN and for() loop but I failed. *My problem is that for each columns the recoding system is

Re: [R] Recode values

2013-11-22 Thread peter dalgaard
On 22 Nov 2013, at 11:13 , lillosdos lillo_dica...@live.it wrote: Hi I'm Pasquale, I need to recode variables (columns) of a dataframe (call it X). The observations (rows) are coded as numeric 0,1,2 and NA. I managed to use the lapply() function with recode() as FUN and for() loop but I