new-vector-along: Create vectors matching the length of a given vector
Description
These functions take the idea of seq_along() and generalise it to
creating lists (new_list_along) and repeating values (rep_along).
Except for new_list_along() and new_raw_along(), the empty
vectors are filled with typed missing values.
Usage
new_logical_along(x, names = base::names(x))
new_integer_along(x, names = base::names(x))
new_double_along(x, names = base::names(x))
new_character_along(x, names = base::names(x))
new_complex_along(x, names = base::names(x))
new_raw_along(x, names = base::names(x))
new_list_along(x, names = base::names(x))
rep_along(.x, .y)
Arguments
x, .x
A vector.
names
Names for the new vector. Defaults to the names of
x. This can be a function to apply to the names of x as in
set_names().
# NOT RUN {x <- 0:5rep_along(x, 1:2)
rep_along(x, 1)
new_list_along(x)
# The default names are picked up from the input vectorx <- c(a = "foo", b = "bar")
new_character_along(x)
# }