[R] replacing NA's with various numbers

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Sat Oct 6 04:34:12 CEST 2007

x[is.na(x)]<- y[is.na(x)] but this will only work correctly if x and y
are the same length so I hope that is
what you mean by the same style.


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Nigel.Walker at studentmail.newcastle.edu.au
Sent: Friday, October 05, 2007 10:28 PM
To: r-help at stat.math.ethz.ch
Subject: [R] replacing NA's with various numbers

I have two vectors in the same style as

that is when x[ i ] = NA,  y[ i ]=numeric. I wish to replace the NA's in
x by the corresponding y value. Any help would be much appreciated.

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

This is not an offer (or solicitation of an offer) to bu...{{dropped:22}}

More information about the R-help mailing list