append_ns | R Documentation |
Uses the output from the y2clerk freqs() function and adds (n = ...) to the end of each label, based off the column "n". Useful for charts that require ns for all levels
append_ns(dataset, append_to = label, by_group_var = FALSE, newline = FALSE)
dataset |
A dataframe |
append_to |
(default: label). The variable to which you wish to add (n = ...) |
by_group_var |
(default: FALSE). If FALSE, takes ns by row. If TRUE, takes group ns by group_var levels. Set to TRUE if making a stacked bar chart |
newline |
(default: FALSE). If FALSE, (n = ...) comes after a space " ". If TRUE, it comes after a hard return |
# by_group_var = FALSE
ToothGrowth %>%
freqs(supp) %>%
append_ns()
ToothGrowth %>%
dplyr::group_by(supp) %>%
freqs(dose) %>%
append_ns(newline = TRUE)
# by_group_var = TRUE
ToothGrowth %>%
dplyr::group_by(supp) %>%
freqs(dose) %>%
append_ns(
append_to = group_var,
by_group_var = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.