Hi all,

I know this issue has been discussed a few times in the past already,
but Martin Maechler suggested in a bug report [1] that I raise it here.

Basically, there is no (easy) way of printing NAs for all variables
when calling xtabs() on factors. Passing 'exclude=NULL,
na.action=na.pass' works for character vectors, but not for factors.

> test <- data.frame(x=c("a",NA))
> xtabs(~ x, exclude=NULL,
na.action=na.pass, data=test)
x
a 
1 

> test <- data.frame(x=factor(c("a",NA)))
> xtabs(~ x, exclude=NULL,
na.action=na.pass, data=test)
x
a 
1 


Even if it's documented, this inconsistency is annoying. When checking
data, it is often useful to print all NA values temporarily, without
calling addNA() individually on all crossed variables.

Would it make sense to add a new argument similar to table()'s useNA
which would behave the same for all input vector types?


Regards


1: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=14630

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to