Re: [R] concatenate values of two columns

2010-05-05 Thread kMan
empty character fields coerce NA, so instead, you test for is.na() df<-data.frame(x=c(1:6), var1=c(NA,1,2,NA,NA,4),var2=c(2,NA,NA,3,4,NA)) dfm<-vector("numeric",6) index1<-!is.na(df$var1) index2<-!is.na(df$var2) dfm[index1]<-df$var1[index1] dfm[index2]<-df$var2[index2]

Re: [R] concatenate values of two columns

2010-05-05 Thread Marshall Feldman
On 5/5/2010 6:00 AM, n.via...@libero.it wrote: Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3

[R] concatenate values of two columns

2010-05-05 Thread n.via...@libero.it
Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3 2 4