Learn R Programming

scrutiny (version 1.0.0)

add_up_to_map: Test whether reported counts add up to their totals

Description

[Experimental]

add_up_to_map() applies add_up_to() to every row of a data frame.

Call audit() on the output for summary statistics.

Usage

add_up_to_map(data, summands, total = NULL, ...)

Value

A tibble with the summands columns, total, consistency, and any other columns from data, with the class scrutiny_add_up_to_map.

Arguments

data

Data frame with a total column and the columns to add up. Any other columns are returned alongside the results.

summands

Columns of data to add up, selected with tidyselect, such as starts_with("n_"). There is no default.

total

Optionally, the name of the column in data that contains the totals, if it isn't total.

...

These dots must be empty.

Summaries with <code>audit()</code>

audit() on add_up_to_map() output returns a tibble with one row and these columns:

  1. all_cases: total number of rows.

  2. incon_cases: number of inconsistent rows.

  3. emp_incon: proportion of inconsistent rows.

Examples

Run this code
df <- tibble::tibble(
  n_control = c(40, 25, 31),
  n_treatment = c(37, 26, 30),
  n_waitlist = c(43, 24, 30),
  total = c(120, 75, 90)
)

df |>
  add_up_to_map(summands = starts_with("n_"))

Run the code above in your browser using DataLab