View source: R/adorn_percentages.R
| adorn_percentages | R Documentation | 
This function defaults to excluding the first column of the input data.frame,
assuming that it contains a descriptive variable, but this can be overridden
by specifying the columns to adorn in the ... argument.
adorn_percentages(dat, denominator = "row", na.rm = TRUE, ...)
dat | 
 A   | 
denominator | 
 The direction to use for calculating percentages. One of "row", "col", or "all".  | 
na.rm | 
 should missing values (including   | 
... | 
 columns to adorn. This takes a <  | 
A data.frame of percentages, expressed as numeric values between 0 and 1.
mtcars %>%
  tabyl(am, cyl) %>%
  adorn_percentages("col")
# calculates correctly even with totals column and/or row:
mtcars %>%
  tabyl(am, cyl) %>%
  adorn_totals("row") %>%
  adorn_percentages()
# 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(, , recovered:died)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.