wtd_mean: Weighted Aggregate Strings

Description Usage Arguments Value

View source: R/weighted_aggregators.R

Description

A set of functions that act as a convenience wrapper to generate a formulas for calculating aggregates of a data frame which requires weighting. This formula is intended to be used in a dplyr summarize_ or mutate_ formula. The defaults are intended for use with the births data set, using the 'cases' field as the default weighting value.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
wtd_mean(numeric_column, weight_column = "cases", na.rm = FALSE)

wtd_median(numeric_column, weight_column = "cases", na.rm = FALSE)

wtd_SD(numeric_column, weight_column = "cases", na.rm = FALSE)

wtd_quantile(numeric_column, q, weight_column = "cases", na.rm = FALSE,
  .summ = FALSE)

wtd_count(column, weight_column = "cases")

wtd_NA_count(column, weight_column = "cases")

Arguments

numeric_column

in the case of numeric aggregation functions (mean, SD), this is the column that is used to aggregate

weight_column

the value that each value is weighted by in calculation of the aggregate

na.rm

a logical indicator of whether NA values should be removed prior to aggregation

q

the quantile value that you desire

.summ

a logical control for whether to use already calculated values for Mean and SD in the data.frame. This is intended for use in a summary function, where quantile values are calculated alongside a Mean and SD value. This prevents the quantile function from recalculating the Mean and SD multiple times.

column

in the case of aggregates which function on non-numeric columns, this is the column that is used

Value

a formula string that can be executed in a dplyr summarize_ statement


Mikuana/vitalstatistics documentation built on May 7, 2019, 4:57 p.m.