rlang (version 0.0.0.9000)

along: Helper to create vectors with matching length.

Description

These functions take the idea of seq_along and generalise it to creating lists (lst_along) and repeating values (rep_along). The dots and .attrs are forwarded to with_attributes() to make it easy to add attributes. Except for lst_along() and raw_along(), the empty vectors are filled with typed missing values.

Usage

lgl_along(.x, ..., .attrs = list())
int_along(.x, ..., .attrs = list())
dbl_along(.x, ..., .attrs = list())
chr_along(.x, ..., .attrs = list())
lst_along(.x, ..., .attrs = list())
cpl_along(.x, ..., .attrs = list())
raw_along(.x, ..., .attrs = list())
rep_along(.x, .y, ..., .attrs = list())

Arguments

.x
A vector.
...
A list of named attributes.
.attrs
A list of named attributes.
.y
Values to repeat.

See Also

new-vectors

Examples

Run this code
x <- 0:5
rep_along(x, 1:2)
rep_along(x, 1)
lst_along(x)

# You can also add attributes with additional arguments:
rep_along(x, 1, class = "my_class")
dbl_along(x, class = "my_class")

Run the code above in your browser using DataCamp Workspace