Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread JKPeck
Thanks for all the suggestions. The last one is certainly minimalist! On Aug 16, 1:20 pm, Dieter Menne <[EMAIL PROTECTED]> wrote: > Gabor Grothendieck gmail.com> writes: > > > is.na(DF) <- is.na(DF) > > I knew you would win the shortest competition. I missed you at the useR > meeting. > > Diete

Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread Dieter Menne
Gabor Grothendieck gmail.com> writes: > is.na(DF) <- is.na(DF) I knew you would win the shortest competition. I missed you at the useR meeting. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read th

Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread Gabor Grothendieck
Try this: is.na(DF) <- is.na(DF) or this which returns a transformed data frame without overwriting DF: replace(DF, is.na(DF), NA) On Fri, Aug 15, 2008 at 10:27 PM, Peck, Jon <[EMAIL PROTECTED]> wrote: > I am looking for the most efficient way to replace all occurrences of NaN in > a data fram

Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread Muenchen, Robert A (Bob)
riday, 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 shoul

Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread Dieter Menne
Peck, Jon spss.com> writes: > > 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

Re: [R] Dealing with NaN's in data frames

2008-08-16 Thread Dimitris Rizopoulos
try this: dat <- data.frame(x = rnorm(10), y = rnorm(10), z = rnorm(10), g = gl(5,2)) dat$x[sample(10, 3)] <- NaN dat$y[sample(10, 3)] <- NaN dat$z[sample(10, 3)] <- NaN dat[] <- lapply(dat, function(x){ x[is.nan(x)] <- NA x }) I hope it helps. Best, Dimitris Peck, Jon wrote: I

[R] Dealing with NaN's in data frames

2008-08-16 Thread Peck, Jon
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. T