[Rd] xtabs and NA
ggrothendieck at gmail.com
Mon Feb 9 16:59:39 CET 2015
On Mon, Feb 9, 2015 at 8:52 AM, Kirill Müller
<kirill.mueller at ivt.baug.ethz.ch> wrote:
> I haven't found a way to produce a tabulation from factor data with NA
> values using xtabs. Please find a minimal example below, it's also on R-pubs
> . Tested with R 3.1.2 and R-devel r67720.
> It doesn't seem to be documented explicitly that it's not supported. From
> reading the code  it looks like the relevant call to table() doesn't set
> the "useNA" parameter, which I think is necessary to make NAs show up in the
> Am I missing anything? If this a bug -- would a patch be welcome? Do we need
> compatibility with the current behavior?
> I'm aware of workarounds, I just prefer xtabs() over table() for its
Passing table the output of model.frame would still allow the use of a
> mf <- model.frame( ~ data, na.action = na.pass)
> do.call("table", c(mf, useNA = "ifany"))
a b c <NA>
1 1 1 1
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
email: ggrothendieck at gmail.com
More information about the R-devel