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)

## Arguments

x A vector. Number of times to repeat each element of x. Number of times to repeat the whole vector of x.

## Value

A vector the same type as x with size vec_size(x) * times * each.

## Examples

# each repeats within
vec_repeat(1:3, each = 2)#> [1] 1 1 2 2 3 3# times repeats whole thing
vec_repeat(1:3, times = 2)#> [1] 1 2 3 1 2 3
df <- data.frame(x = 1:2, y = 1:2)
# rep() repeats columns of data frame, and returns list:
rep(df, each = 2)#> $x #> [1] 1 2 #> #>$x
#> [1] 1 2
#>
#> $y #> [1] 1 2 #> #>$y
#> [1] 1 2
#> # vec_repeat() repeats rows, and returns same data.frame
vec_repeat(df, 2)#>   x y
#> 1 1 1
#> 2 1 1
#> 3 2 2
#> 4 2 2