vec_recycle | R Documentation |
vec_recycle(x, size)
recycles a single vector to a given size.
vec_recycle_common(...)
recycles multiple vectors to their common size. All
functions obey the vctrs recycling rules, and will
throw an error if recycling is not possible. See vec_size()
for the precise
definition of size.
vec_recycle(x, size, ..., x_arg = "", call = caller_env())
vec_recycle_common(..., .size = NULL, .arg = "", .call = caller_env())
x |
A vector to recycle. |
size |
Desired output size. |
... |
Depending on the function used:
|
x_arg |
Argument name for |
call , .call |
The execution environment of a currently
running function, e.g. |
.size |
Desired output size. If omitted,
will use the common size from |
.arg |
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem. |
vec_slice()
# Inputs with 1 observation are recycled
vec_recycle_common(1:5, 5)
vec_recycle_common(integer(), 5)
## Not run:
vec_recycle_common(1:5, 1:2)
## End(Not run)
# Data frames and matrices are recycled along their rows
vec_recycle_common(data.frame(x = 1), 1:5)
vec_recycle_common(array(1:2, c(1, 2)), 1:5)
vec_recycle_common(array(1:3, c(1, 3, 1)), 1:5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.