nickr_group: Check that a condition holds on groups of data between pipe...

Description Usage Arguments Value Examples

Description

Expressions can use special functions like n() that are allowed in summarize calls. This function should only be put in pipes after group_by has been called (so that groups exist).

Usage

1
2
nickr_group(.data, cond, msg = "nickr_row", active = TRUE,
  logger = stop)

Arguments

.data

Incoming data (omitted if in pipe).

cond

Condition written using column names and aggregation functions.

msg

User message to display if test fails.

active

Is this check turned on (default TRUE). Set FALSE to disable test (e.g., in production).

logger

Function to call with message (e.g., 'warning' or 'stop').

Value

Input data without modification.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
data %>%
  # Preliminary processing.
  mutate(...) %>%

  # Aggregation.
  group_by(person_id) %>%

  # Warn if there are less than 5 records in any group in production.
  nickr_group(n() >= 5, msg = "Should have at least 5 records",
              active = IN.PRODUCTION, logger = warning)

  # Further processing on unmodified data.
  summarize(...)

## End(Not run)

gvwilson/nickr documentation built on May 9, 2019, 4:05 p.m.