Hi > > Hello, > I have a big data.frame, a piece of it as follows. > > a b c d > 1 58009 2010-11-02 0 NA > 2 114761 NA 1 2008-11-05 > 3 184440 NA 1 2009-12-08 > 4 189372 NA 0 NA > 5 105286 NA 0 NA > 6 186717 NA 0 NA > 7 189106 NA 0 NA > 8 127306 NA 0 NA > 9 157342 2011-04-25 0 NA > > I want to replace b[NA] values with "20011-07-28" where c==0. I use rstudio > and i'm a novice.
I believe there are better solutions but I would use two steps select rows where c==0 (see also FAQ 7.31) sel<-which(big.data.frame$c==0) change NA values in b column based on sel big.data.frame$b[sel][is.na(big.data.frame$b[sel])]<-"20011-07-28" Beware of data types AFAIK R can not accept "20011-07-28" as a date. Regards Petr > > > -- > View this message in context: http://r.789695.n4.nabble.com/conditional- > data-replace-recode-change-or-whatsoever-tp3714715p3714715.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.