Re: [R] Combine two variables

2012-09-11 Thread arun
Hi,   I am not sure how you describe combine. Try this: df1<-subset(df, !is.na(var1) &!is.na(var2)) df1$new<-paste0(df1$var1,df1$var2) > head(df1) #  var1 var2 new #1    b    a  ba #2    c    b  cb #3    b    b  bb #5    a    a  aa #6    b    b  bb #7    a    b  ab A.K. - Original Message

Re: [R] Combine two variables

2012-09-11 Thread PIKAL Petr
Hi I am not sure I understand correctly. In the sample dataframe you posted, the values in columns are different so based on what you did write I aasume that apply(df,1, paste, collapse="") gives you third variable combined from those 2 variables. If you want to select non NA value from any va

Re: [R] Combine two variables

2012-09-11 Thread Rui Barradas
Hello, Inline. Em 11-09-2012 15:57, Simon Kiss escreveu: Hi: I have two variables in a data frame that are the results of a wording experiment in a survey. I'd like to create a third variable that combines the two variables. Recode doesn't seem to work, because it just recodes the first var