[R] Merge two vectors into one.
Gábor Csárdi
csardi at rmki.kfki.hu
Wed Jan 28 16:01:11 CET 2009
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_84 at 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.Csardi at unil.ch> UNIL DGM
More information about the R-help
mailing list