total_percentage: Get totals and percentages.

Description Usage Arguments Examples

Description

Get totals and percentages.

Usage

1
total_percentage(totals, percentages, ...)

Arguments

totals

data.frame with totals.

percentages

data.frame with percentages.

...

Additional arguments.

Examples

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)

animalito/rformat documentation built on May 10, 2019, 11:49 a.m.