Check if the provided object has expected length
Source:R/validation-expected-length.R
isOfLength.RdCheck if the provided object has expected length
Value
isOfLength()returnsTRUEif the object or all objects inside the list havenbElements.For
validateIsOfLength(), if validations are successful,NULLis returned. Otherwise, error is signaled.
Examples
df <- data.frame(x = c(1, 2, 3))
isOfLength(df, 1) # TRUE
#> [1] TRUE
isOfLength(df, 3) # FALSE
#> [1] FALSE
validateIsOfLength(list(1, 2), 2L) # NULL
#> NULL
# validateIsOfLength(c("3", "4"), 3L) # error