Re: [R] Replacing NAs in one variable with values of another variable

2011-08-24 Thread StellathePug
Thank you Dan and Ista! Both of you are correct, I should have used NA rather than "NA" in my example. So the correct code should be: X <-as.data.frame(matrix(c(9, 6, 1, 3, 9, NA, NA,NA,NA,NA, 6, 4, 3,NA, NA, NA, 5, 4, 1, 3), ncol=2)) names(X)<-c("X1","X2") X$X1[

Re: [R] Replacing NAs in one variable with values of another variable

2011-08-23 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Ista Zahn > Sent: Tuesday, August 23, 2011 11:06 AM > To: StellathePug > Cc: r-help@r-project.org > Subject: Re: [R] Replacing NAs in one variable w

Re: [R] Replacing NAs in one variable with values of another variable

2011-08-23 Thread Ista Zahn
Hi, On Tue, Aug 23, 2011 at 12:29 PM, StellathePug wrote: > Hello everyone, > I am trying to figure out a way of replacing missing observations in one of > the variables of a data frame by values of another variable. For example, > assume my data is X > > X <-as.data.frame(matrix(c(9, 6, 1, 3, 9,

[R] Replacing NAs in one variable with values of another variable

2011-08-23 Thread StellathePug
Hello everyone, I am trying to figure out a way of replacing missing observations in one of the variables of a data frame by values of another variable. For example, assume my data is X X <-as.data.frame(matrix(c(9, 6, 1, 3, 9, "NA", "NA","NA","NA","NA", 6, 4, 3,"NA", "NA", "NA