Skip to content
Prev 361976 / 398506 Next

Subscripting problem with is.na()

As Petr and Don have shown you, changing NA to 0 is unnecessary to get
what you want. However, recoding to 0 may be OK, as NA has a specific
meaning in this context, and you are just adding an extra code to a
factor for a different level.

But it still might cause you trouble later. One of R's strengths is
it's ability to simply deal with NA's -- most of the time anyway .For
example note that you would have to make sure these columns are
factors (*not numerics*), if you wanted to, say, investigate how
category of closing related to other covariates via e.g. multinomial
logistic regression or even just to tabulate the "closed" categories.
Keeping NA as NA allows R's built-in facilities to simply handle (e.g.
omit) the data for the "still open" cases, but you will have to do it
explicitly yourself if you code to 0. That seems to be asking for
trouble to me.

As always, contrary views welcome. This discussion still seems on
(r-help) topic to me, but if not, please say so.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Jun 24, 2016 at 12:14 AM, <G.Maubach at gmx.de> wrote: