check_nrows()
checks if the number of rows (n
) falls within
a specified range, defined by min
and max
. The function
ensures that n
is an integer and meets the specified conditions.
If allow_null
is TRUE
, n
can be NULL
.
Otherwise, an error is raised if n
is not within the specified
bounds.
Value
Returns the number of rows n
if it satisfies the specified
conditions. Otherwise, an error is raised.
Examples
check_nrows(5, min = 1, max = 10)
#> [1] 5
try(check_nrows(15, min = 1, max = 10))
#> Error in check_numeric(num = n, min = min, max = max, is_integer = TRUE, :
#> Expected 'nrows' to be an integer (whole number) between 1 and 10 inclusive but got 15
check_nrows(0, min = 0, max = 10)
#> [1] 0
try(check_nrows(-3, min = 1, max = 10))
#> Error in check_numeric(num = n, min = min, max = max, is_integer = TRUE, :
#> Expected 'nrows' to be an integer (whole number) between 1 and 10 inclusive but got -3