[R] replace NA with another vector
arun
smartpink111 at yahoo.com
Tue Dec 24 18:08:40 CET 2013
z <- x
z[is.na(z)] <- y
z
#[1] 20 40 3 50 1
A.K.
On Tuesday, December 24, 2013 12:06 PM, Kathryn Lord <kathryn.lord2000 at gmail.com> wrote:
Dear R users,
I have two different vectors like below
x <- c( NA, NA, 3, NA, 1)
y <- c( 20, 40 ,50)
Combining x and y, I'd like to create new vector z
z <- c(20, 40, 3, 50, 1)
Any suggestion will be greatly appreciated.
Best,
Kathryn Lord
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list