Spread an integer to a given length
Value
If x
is a scalar whole number value (see is.wholenumber()
), the value x
is repeated len
times.
Otherwise, an error is thrown.
Examples
spread_integer(3, 1)
#> [1] 3
spread_integer(0, 3)
#> [1] 0 0 0
spread_integer(1, 3)
#> [1] 1 0 0
spread_integer(2, 3)
#> [1] 1 1 0
spread_integer(3, 3)
#> [1] 1 1 1
spread_integer(4, 3)
#> [1] 2 1 1
spread_integer(5, 3)
#> [1] 2 2 1
spread_integer(6, 3)
#> [1] 2 2 2
spread_integer(7, 3)
#> [1] 3 2 2