Inconsistency of na.action between xtabs and aggregate in R
问题 I have the following data.frame: x <- data.frame(A = c("Y", "Y", "Z", NA), B = c(NA, TRUE, FALSE, TRUE), C = c(TRUE, TRUE, NA, FALSE)) And I need to compute the following table with xtabs : A B C Y 1 2 Z 0 0 <NA> 1 0 I was told to use na.action = NULL, which indeed returns the table I need: xtabs(formula = cbind(B, C) ~ A, data = x, addNA = TRUE, na.action = NULL) A B C Y 1 2 Z 0 0 <NA> 1 0 However, na.action = na.pass returns a different table: xtabs(formula = cbind(B, C) ~ A, data = x,