Hi,
Sorry, the answers are yes yes yes. And thank you for your idea it works perfectly. Regards Patricia > Date: Wed, 28 Jan 2009 16:01:11 +0100 > Subject: Re: [R] Merge two vectors into one. > From: csa...@rmki.kfki.hu > To: kurtney...@hotmail.com > CC: r-help@r-project.org > > 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 _________________________________________________________________ [[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.