vec_repeat {vctrs} | R Documentation |
This is a special case of rep()
for the special case of integer times
and each
values, and works along size, rather than length.
vec_repeat(x, each = 1L, times = 1L)
x |
A vector. |
each |
Number of times to repeat each element of |
times |
Number of times to repeat the whole vector of |
A vector the same type as x
with size vec_size(x) * times * each
.
# each repeats within vec_repeat(1:3, each = 2) # times repeats whole thing vec_repeat(1:3, times = 2) df <- data.frame(x = 1:2, y = 1:2) # rep() repeats columns of data frame, and returns list: rep(df, each = 2) # vec_repeat() repeats rows, and returns same data.frame vec_repeat(df, 2)