Hi Jon, Here's one way.
> x <- c(1,2,3,4,NaN) > y <- c(1,2,NaN,4,5) > > myDF <- data.frame(x,y) > myDF x y 1 1 1 2 2 2 3 3 NaN 4 4 4 5 NaN 5 > > myDF[ is.na(myDF) ] <- NA > myDF x y 1 1 1 2 2 2 3 3 NA 4 4 4 5 NA 5 Cheers, Bob ========================================================= Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of Information Technology 200 Stokely Management Center, Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: [EMAIL PROTECTED] Web: http://oit.utk.edu/scc, News: http://listserv.utk.edu/archives/statnews.html ========================================================= > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of Peck, Jon > Sent: Friday, August 15, 2008 10:28 PM > To: r-help@r-project.org > Subject: [R] Dealing with NaN's in data frames > > I am looking for the most efficient way to replace all occurrences of > NaN in a data frame with NA. I can do this with a double loop, but it > seems that there should be a higher level and more efficient way. With > is.na, I could use ifelse, but if.nan seems not to have similar > capabilities. > > > > TIA, > > Jon Peck > > > > Jon K. Peck > > [EMAIL PROTECTED] > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.