Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DanChaltiel opened this issue May 17, 2024 · 0 comments
Open

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

DanChaltiel opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DanChaltiel
Copy link
Owner

DanChaltiel commented May 17, 2024

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 DanChaltiel added the bug Something isn't working label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant