DanChaltiel / crosstable

Easy and thorough description of datasets
https://danchaltiel.github.io/crosstable/
112 stars 8 forks source link

fails when `total=TRUE` if a factor has no NA but has NA levels #63

Closed DanChaltiel closed 2 months ago

DanChaltiel commented 5 months ago

replace .showNA = showNA == "always" || showNA == "ifany" && (anyNA(x)) by .showNA = showNA == "always" || showNA == "ifany" && (anyNA(x) || anyNA(levels(x)))

reprex:

debugonce(crosstable:::summarize_categorical_single)
a = mtcars2 %>% 
  mutate(am = ifelse(runif(n())>.8 & vs=='vshaped', NA, am) %>% factor() %>% fct_na_value_to_level()) 
a %>% crosstable(am, by=vs, total="row")
DanChaltiel commented 2 months ago

seems to be fixed in v0.7.0.9009