mtcars %>%
tabyl(am, cyl) %>%
adorn_percentages() %>%
adorn_rounding(digits = 2, rounding = "half up")
# tolerates non-numeric columns:
library(dplyr)
mtcars %>%
tabyl(am, cyl) %>%
adorn_percentages("all") %>%
mutate(dummy = "a") %>%
adorn_rounding()
# Control the columns to be adorned with the ... variable selection argument
# If using only the ... argument, you can use empty commas as shorthand
# to supply the default values to the preceding arguments:
cases <- data.frame(
region = c("East", "West"),
year = 2015,
recovered = c(125, 87),
died = c(13, 12)
)
cases %>%
adorn_percentages(,,ends_with("ed")) %>%
adorn_rounding(,,one_of(c("recovered", "died")))
Run the code above in your browser using DataLab