Learn R Programming

keyed (version 0.1.3)

lock_nrow: Assert row count within expected range

Description

Checks that the number of rows is within an expected range. Useful for sanity checks after filtering or joins.

Usage

lock_nrow(.data, min = 1, max = Inf, expected = NULL, .strict = FALSE)

Value

Invisibly returns .data (for piping).

Arguments

.data

A data frame.

min

Minimum expected rows (inclusive). Default 1.

max

Maximum expected rows (inclusive). Default Inf.

expected

Exact expected row count. If provided, overrides min/max.

.strict

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

Examples

Run this code
df <- data.frame(id = 1:100)
lock_nrow(df, min = 50, max = 200)
lock_nrow(df, expected = 100)

Run the code above in your browser using DataLab