powered by
Checks that the number of rows is within an expected range. Useful for sanity checks after filtering or joins.
lock_nrow(.data, min = 1, max = Inf, expected = NULL, .strict = FALSE)
Invisibly returns .data (for piping).
.data
A data frame.
Minimum expected rows (inclusive). Default 1.
Maximum expected rows (inclusive). Default Inf.
Exact expected row count. If provided, overrides min/max.
If TRUE, error on failure. If FALSE (default), warn.
TRUE
FALSE
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