L {pkgutils} | R Documentation |
Raise an error if one to several given R objects do not have the specified length. This is mainly used to easily generate meaningful error messages related to function arguments.
L(x, .wanted = 1L, .msg = "need object '%s' of length %i", .domain = NULL) LL(..., .wanted = 1L, .msg = "need object '%s' of length %i", .domain = NULL)
x |
R object to test. |
... |
Any R objects to test. |
.wanted |
Integer scalar giving the desired length.
Note that this can not be a scalar with
‘double’ as |
.msg |
Error message passed to |
.domain |
Passed to |
If successful, L
returns x
, but an error
message is raised if length(x)
is not identical to
wanted
. LL
yields the names of the
arguments contained in ...
, returned invisibly,
if successful. Otherwise an error is raised.
base::stop
Other coding-functions: assert
,
case
, check
, collect
,
contains
, flatten
,
listing
, map_names
,
map_values
, must
,
set
, sql
,
unnest
(x <- L(letters, 26L)) stopifnot(identical(x, letters)) (x <- try(L(letters, 25L), silent = TRUE)) stopifnot(inherits(x, "try-error")) (x <- LL(letters, LETTERS, .wanted = 26L)) stopifnot(x == c("letters", "LETTERS"))