Handeling NaN values in output table

I am trying to create a summary for calculating mean,median average but somewhere getting NaN values in my summary , now i want to replace NaN with "0.0"

average Mean Median total
NaN NaN NaN 0

I am trying like below
but when i am checking class of tabl is data.frame

Tabl[2, ](is.nan(Tabl[2, ])) <- "0.0"
Error in is.nan(`*tmp*`) : default method not implemented for type 'list'

I think you want to use is.na() rather than is.nan(). They do for some reason behave differently, is it maybe because of the different forms a missing value can have?

And if you want to replace only the NAs in row 2 (that's how I understand your code example), you need to wrap the is.na(...) in squared brackets and not in normal ones (it's just a second indexing).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.