Description Usage Arguments Value Examples
This function adds back the underlying Ns to a tabyl
whose percentages were calculated using adorn_percentages()
, to display the Ns and percentages together. You can also call it on a non-tabyl data.frame to which you wish to append Ns.
1 |
dat |
a data.frame of class |
position |
should the N go in the front, or in the rear, of the percentage? |
ns |
the Ns to append. The default is the "core" attribute of the input tabyl |
... |
columns to adorn. This takes a tidyselect specification. By default, all columns are adorned except for the first column and columns not of class |
a data.frame with Ns appended
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | mtcars %>%
tabyl(am, cyl) %>%
adorn_percentages("col") %>%
adorn_pct_formatting() %>%
adorn_ns(position = "front")
# 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("col",,recovered:died) %>%
adorn_pct_formatting(,,,recovered:died) %>%
adorn_ns(,,recovered:died)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.