View source: R/are-same-size.R
are_same_length | R Documentation |
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())
x |
An R object or expression. |
y |
Another R object or expression. |
.xname |
Not intended to be used directly. |
.yname |
Not intended to be used directly. |
... |
Some R expressions. |
l |
A list of R expressions. |
severity |
How severe should the consequences of the assertion be?
Either |
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.)
length
, are_identical
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.