nickr_row: Check that a condition holds on the rows of data between pipe...

Description Usage Arguments Details Value Examples

Description

This is used much less frequently than nickr_col, since most tests are both easier to express and more efficient to run on columns, but it does have occasional uses. See nickr_col for examples of using the active and logger arguments.

Usage

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

Arguments

.data

Incoming data (omitted if in pipe).

cond

Condition written using column names, .ri, and .row.

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').

Details

Each row is augmented with .ri for the row index and .row to hold the entire original row as a list.

Value

Input data without modification.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
data %>% mutate(...) %>%

  # Check that at most one field is zero in any row.
  nickr_row(sum(as.double(.row) == 0) <= 1,
            msg = "at most one zero per row") %>%

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

## End(Not run)

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