Description Usage Arguments Examples
Get totals and percentages.
1 | total_percentage(totals, percentages, ...)
|
totals |
data.frame with totals. |
percentages |
data.frame with percentages. |
... |
Additional arguments. |
1 2 3 4 5 | library(tidyr)
totals <- data.frame(names = letters[1:5], x = rnorm(5, 500, 200), y = rnorm(5, 500, 200))
per <- tidyr::gather(totals, key = key, value = value, -names) %>% dplyr::group_by(key) %>% dplyr::mutate(percentage = value/sum(value) * 100) %>% dplyr::select(-value) %>% tidyr::spread(key = key, value = percentage) %>% data.frame()
total_percentage(totals, per)
total_percentage(totals, per, fnames = F)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.