Hi r-help-boun...@r-project.org napsal dne 05.05.2010 11:46:33:
> > 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 3 > 5 4 > 6 4 > > > what i would like to obtain is: > X VAR3 > 1 2 > 2 1 > 3 2 > 4 3 > 5 4 > 6 4 > > I try with paste but what I obtain is: > X VAR3 > > 1 NA2 > 2 1NA > > 3 2NA > > 4 NA3 > > 5 NA4 > > 6 4NA If your variables are numeric and if there are no values in both columns i.e. when Var1 is NA Var 2 is number you can rowSums(data.frame[,c("VAR1","VAR2")], na.rm=T) Regards Petr > > Thanks a lot!! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.