Split vector into equal pieces

Splits a vector in pieces with defined length and a remainder. Useful when to split datasets by ID for plotting over several pages.

aux_splitVectorEqualPieces(x, n)

Arguments

x

Vector to be splitted

n

Number of elements per piece

Value

List with the split pieces

Examples

x <- 1:20
aux_splitVectorEqualPieces(x,3)
#> [[1]]
#> [1] 1 2 3
#> 
#> [[2]]
#> [1] 4 5 6
#> 
#> [[3]]
#> [1] 7 8 9
#> 
#> [[4]]
#> [1] 10 11 12
#> 
#> [[5]]
#> [1] 13 14 15
#> 
#> [[6]]
#> [1] 16 17 18
#> 
#> [[7]]
#> [1] 19 20 NA
#>