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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, October 05, 2007 10:28 PM To: [EMAIL PROTECTED] Subject: [R] replacing NA's with various numbers Hi I have two vectors in the same style as x<-c(NA,NA,1,3,4,NA,1) y<-c(0,0,NA,NA,NA,0,NA) 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. Nigel ______________________________________________ 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. -------------------------------------------------------- This is not an offer (or solicitation of an offer) to bu...{{dropped:22}} ______________________________________________ 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.