I have a dataframe & wish to convert the NA (missing values) to zero . In SAS I would use options missing=0 to convert all my obs in a dataset. How can I accomplish the same thing in R? Can it be done? Thanks for any thoughts on this. -- View this message in context: http://r.789695.n4.nabble.com/What-is-SAS-options-missing-0-equivalent-in-R-tp4663090.html Sent from the R help mailing list archive at Nabble.com.
google "r replace NA with 0" (without the quotes). On Tue, Apr 2, 2013 at 10:49 AM, ramoss <ramine.mossadegh at finra.org> wrote:> I have a dataframe & wish to convert the NA (missing values) to zero . In SAS > I would use options missing=0 to convert all my obs in a dataset. How can I > accomplish the same thing in R? Can it be done? Thanks for any thoughts on > this. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/What-is-SAS-options-missing-0-equivalent-in-R-tp4663090.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
On Apr 2, 2013, at 16:49 , ramoss wrote:> I have a dataframe & wish to convert the NA (missing values) to zero . In SAS > I would use options missing=0 to convert all my obs in a dataset. How can I > accomplish the same thing in R? Can it be done? Thanks for any thoughts on > this. >The straightforward way would be d[is.na(d)] <- 0 ---with some caveats if you have non-numeric data in some columns.> > > -- > View this message in context: http://r.789695.n4.nabble.com/What-is-SAS-options-missing-0-equivalent-in-R-tp4663090.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.-- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com