Re: [R] NaN, Inf to NA

2011-05-27 Thread William Dunlap
> -Original Message- > From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] > Sent: Friday, May 27, 2011 5:23 AM > To: Albert-Jan Roskam > Cc: William Dunlap; Marc Schwartz; R Mailing List > Subject: Re: [R] NaN, Inf to NA > > On 11-05-27 4:27 AM, Albert-J

Re: [R] NaN, Inf to NA

2011-05-27 Thread Martin Maechler
>> it here) >> >> ditch<- function(x) ifelse(is.infinite(x) | is.nan(x), >> NA, x) df<- apply(df, 2, ditch) >> >> >> >> >> >> From: William >> Dunlap

Re: [R] NaN, Inf to NA

2011-05-27 Thread Duncan Murdoch
liam Dunlap Cc: R Mailing List Sent: Fri, May 27, 2011 12:57:01 AM Subject: RE: [R] NaN, Inf to NA I think the source of the OP's problem is that while things like df>30 and is.na(df) return a logical matrix with the dimensions of the data.frame df, both is.infinite(df) and is.nan(df)

Re: [R] NaN, Inf to NA

2011-05-27 Thread Kenn Konstabel
(a=c(NA, NaN, Inf, 1:3), b=c(2,NaN)) df[] <- lapply(df, function(x) ifelse(is.finite(x), x, NA)) KK > > > > > > From: William Dunlap > > Cc: R Mailing List > Sent: Fri, May 27, 2011 12:57:01 AM > Subject: RE: [R] NaN, Inf to NA &g

Re: [R] NaN, Inf to NA

2011-05-27 Thread Albert-Jan Roskam
27, 2011 12:57:01 AM Subject: RE: [R] NaN, Inf to NA I think the source of the OP's problem is that while things like df>30 and is.na(df) return a logical matrix with the dimensions of the data.frame df, both is.infinite(df) and is.nan(df) return a logical vector as long as the number of c

Re: [R] NaN, Inf to NA

2011-05-26 Thread William Dunlap
Sent: Thursday, May 26, 2011 2:15 PM > To: Albert-Jan Roskam > Cc: R Mailing List > Subject: Re: [R] NaN, Inf to NA > > On May 26, 2011, at 3:18 PM, Albert-Jan Roskam wrote: > > > Hi, > > > > I want to recode all Inf and NaN values to NA, but I;m > surpris

Re: [R] NaN, Inf to NA

2011-05-26 Thread Marc Schwartz
On May 26, 2011, at 3:18 PM, Albert-Jan Roskam wrote: > Hi, > > I want to recode all Inf and NaN values to NA, but I;m surprised to see the > result of the following code. Could anybody enlighten me about this? > >> df <- data.frame(a=c(NA, NaN, Inf, 1:3)) >> df[is.infinite(df) | is.nan(df)] <

Re: [R] NaN, Inf to NA

2011-05-26 Thread Ian Gow
> df$a[is.infinite(df$a) | is.nan(df$a) ] <- NA > df a 1 NA 2 NA 3 NA 4 1 5 2 6 3 On 5/26/11 3:18 PM, "Albert-Jan Roskam" wrote: >Hi, > >I want to recode all Inf and NaN values to NA, but I;m surprised to see >the >result of the following code. Could anybody enlighten me about this? > >>

[R] NaN, Inf to NA

2011-05-26 Thread Albert-Jan Roskam
Hi, I want to recode all Inf and NaN values to NA, but I;m surprised to see the result of the following code. Could anybody enlighten me about this? > df <- data.frame(a=c(NA, NaN, Inf, 1:3)) > df[is.infinite(df) | is.nan(df)] <- NA > df a 1 NA 2 NaN 3 Inf 4 1 5 2 6 3 > Thanks!