Are the inputs the same length/dimension?

Checks if the inputs are the same length, or have the same dimensions.

are_same_length(x, y, .xname = get_name_in_parent(x), .yname = get_name_in_parent(y))
have_same_dims(x, y, .xname = get_name_in_parent(x), .yname = get_name_in_parent(y))
are_same_length_legacy(..., l = list())
assert_are_same_length(x, y, severity = getOption("assertive.severity", "stop"))
assert_have_same_dims(x, y, severity = getOption("assertive.severity", "stop"))
assert_all_are_same_length_legacy(..., l = list())
assert_all_are_same_length(..., l = list())
assert_any_are_same_length_legacy(..., l = list())
assert_any_are_same_length(..., l = list())
An R object or expression.
Another R object or expression.
Not intended to be used directly.
Not intended to be used directly.
Some R expressions.
A list of R expressions.
How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

are_same_length and have_same_dims return TRUE if x and y have the same length, or their dimensions are identical. The assert_* functions throw an error on failure.The legacy function are_same_length_legacy allows an arbitrary number of inputs and returns a symmetric square logical matrix which is TRUE where pairs of inputs are the same length. (The new version of the function is easier to work with, and it is recommended that you switch your code to it.)

See Also

length, are_identical

  • are_same_length
  • are_same_length_legacy
  • assert_all_are_same_length
  • assert_all_are_same_length_legacy
  • assert_any_are_same_length
  • assert_any_are_same_length_legacy
  • assert_are_same_length
  • assert_have_same_dims
  • have_same_dims
library( are_same_length(runif(5), list(1, 2:3, 4:6, 7:10, 11:15)) assertive.base::dont_stop( assert_are_same_length(runif(6), list(1, 2:3, 4:6, 7:10, 11:15)) ) have_same_dims( matrix(1:12, nrow = 4), data.frame(x = 1:4, y = 5:8, y = 9:12) ) have_same_dims(1:5, matrix(1:5))
Documentation reproduced from package, version 0.0-4, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.