[R] replacing NaN for every attribute in my data

mishkind mishkind at gmail.com
Wed Jul 11 20:36:48 CEST 2012


Hi,
I have a list called ds which has the following attributes:

attributes(ds)
$names
[1] "adj.r.squared" "fstatistic"    "intercept"     "slope"        
[5] "std.error"     "tstatistic"   

I want to replace all the NaN is ds with 0, and after searching past posts I
found I can hardcode it like this:
ds$adj.r.squared=replace(ds$adj.r.squared,is.nan(ds$adj.r.squared),0)
ds$fstatistic=replace(ds$fstatistic,is.nan(ds$fstatistic),0)
...
ds$tstatistic=replace(ds$tstatistic,is.nan(ds$tstatistic),0)

But, there has to be a more elegant/general solution. I've tried messing
around with lapply but can't seem to get it to work.

Any suggestion?
thanks,
mishkin

--
View this message in context: http://r.789695.n4.nabble.com/replacing-NaN-for-every-attribute-in-my-data-tp4636160.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list