# NOT RUN {
mtcars %>%
crosstab(am, cyl) %>%
ns_to_percents(denom = "all")
# when total_n is needed
mtcars %>%
crosstab(am, cyl) %>%
adorn_totals("row") %>% # add a totals row that should not be included in the denominator
ns_to_percents(denom = "all", total_n = nrow(mtcars)) # specify correct denominator
# }
Run the code above in your browser using DataLab