Re: [Rd] xtabs and NA
On 09.02.2015 16:59, Gabor Grothendieck wrote: On Mon, Feb 9, 2015 at 8:52 AM, Kirill Müller kirill.muel...@ivt.baug.ethz.ch wrote: Passing table the output of model.frame would still allow the use of a formula interface: mf - model.frame( ~ data, na.action = na.pass) do.call(table, c(mf, useNA = ifany)) abc NA 1111 Fair enough, this qualifies as a workaround, and IMO this is how xtabs should handle it internally to allow writing xtabs(~data, na.action = na.pass) -- or at least xtabs(~data, na.action = na.pass, exclude = NULL) if backward compatibility is desired. Would anyone with write access to R's SVN repo care enough about this situation to review a patch? Thanks. -Kirill __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] xtabs and NA
On Mon, Feb 9, 2015 at 8:52 AM, Kirill Müller kirill.muel...@ivt.baug.ethz.ch wrote: Hi 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 [1]. 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 [2] 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 result. 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 interface. Passing table the output of model.frame would still allow the use of a formula interface: mf - model.frame( ~ data, na.action = na.pass) do.call(table, c(mf, useNA = ifany)) abc NA 1111 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel