Checks dimension of an object.
Usage
check_dim(x, dim = length, values = numeric(0), x_name = NULL, dim_name = NULL)
See also
Other check:
check_data()
,
check_dirs()
,
check_files()
,
check_key()
,
check_names()
,
check_values()
Examples
check_dim(1)
try(check_dim(1, values = FALSE))
#> Error in check_dim(1, values = FALSE) : `length(1)` must be equal to 0L.
#> Use `rlang::last_error()$y` to show the object compared to.
try(check_dim(1, values = c(10, 2)))
#> Error in check_dim(1, values = c(10, 2)) :
#> `length(1)` must be between 2 and 10, not 1.
try(check_dim(data.frame(x = 1), dim = nrow, values = c(10, 10, 2)))
#> Error in check_dim(data.frame(x = 1), dim = nrow, values = c(10, 10, 2)) :
#> `nrow(data.frame(x = 1))` must match 2 or 10, not 1.