Is position important? The vectors always have the same length? They always have the same entry if both are not NA?
If yes, yes and yes, then res <- ifelse( is.na(x), y, x) does what you want. Otherwise please explain better what you want. Gabor On Wed, Jan 28, 2009 at 3:54 PM, patricia garcía gonzález <kurtney...@hotmail.com> wrote: > > Hi all, > > I have two vectors like this: > > > x <- c( "Y", "H", NA, NA ) > > y <- c( NA, "H", NA, "B" ) > > And would like to make one vector with the common elements, and the element > available only in one of the vectors. > > > res <- c( "Y", "H", NA, "B" ) > > > Thanks, > > Patricia > -- Gabor Csardi <gabor.csa...@unil.ch> UNIL DGM ______________________________________________ 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.