aggregate_where: Conditional aggregation

Description Usage Arguments Examples

View source: R/frontend_functions.R

Description

Aggregate a column where some condition is true - meant to be used inside tidy functions. This is not even a convenience function as it can be done simpler in native tidyverse (se examples). The function exists in order to highlight a programming pattern.

Usage

1
aggregate_where(fun, var, cond)

Arguments

fun

The aggregation function to run

var

The variable to run the function on

cond

The condition to filter on

Examples

1
2
3
4
5
6
7
## Not run: 
mutate(msft, fincol = aggregate_where(mean, adj_close, change=="UP") )

# Equivalent to
mutate(msft, fincol = mean(adj_close[change=="UP"] ))

## End(Not run)

radbrt/rowpatternmatcher documentation built on Nov. 5, 2019, 2:07 a.m.