calculate_share: Calcuate grand total share

Description Usage Arguments Examples

Description

This function calculates the share of grand total by a selected, grouping variable. If you want to caculate the share in a group by manner you can use the nest-mutate-map combination. See examples for an illustration.

Usage

1

Arguments

df

A a data frame

grouping

Variable to calculate the share for

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
recipes::credit_data %>%
  first_to_lower() %>%
  calculate_share(marital)

recipes::credit_data %>%
  first_to_lower() %>%
  nest(-marital) %>%
  mutate(stats = purrr::map(data, calculate_share, job)) %>%
  select(marital, stats) %>%
  unnest()

konradsemsch/aider documentation built on May 22, 2019, 2:40 p.m.