Learn R Programming

keyed (version 0.1.3)

lock_coverage: Assert minimum coverage of values

Description

Checks that the fraction of non-NA values meets a threshold. Useful after joins to verify expected coverage.

Usage

lock_coverage(.data, threshold, ..., .strict = FALSE)

Value

Invisibly returns .data (for piping).

Arguments

.data

A data frame.

threshold

Minimum fraction of non-NA values (0 to 1).

...

Column names (unquoted) to check. If empty, checks all columns.

.strict

If TRUE, error on failure. If FALSE (default), warn.

Examples

Run this code
df <- data.frame(id = 1:10, x = c(1:8, NA, NA))
lock_coverage(df, 0.8, x)
lock_coverage(df, 0.9, x)  # warns (only 80% coverage)

Run the code above in your browser using DataLab