Splits a vector into list of vectors by chunk or size
split_vector(vec, chunks = NA, percent = NA, size = NA)
| vec | vector; The vector to split |
|---|---|
| chunks | integer; x > 0; The number of desired sub-lists |
| percent | numeric; 100 > x > 0; The maximum percentage of elements each sub-list should hold |
| size | integer; x > 0; The maximum size of each sub-list |
A list of sub-vectors
Splits a vector into consistantly sized sub-lists. The sub-list size will always be decreasing based on list order.
#> [[1]] #> [1] 1 2 #> #> [[2]] #> [1] 3 4 #> #> [[3]] #> [1] 5 6 #> #> [[4]] #> [1] 7 8 #>#> [[1]] #> [1] 1 2 #> #> [[2]] #> [1] 3 4 #> #> [[3]] #> [1] 5 6 #> #> [[4]] #> [1] 7 8 #># Split vector into sub-vectors each with 25% of the total elements split_vector(c(1,2,3,4,5,6,7,8),percent=25)#> [[1]] #> [1] 1 2 #> #> [[2]] #> [1] 3 4 #> #> [[3]] #> [1] 5 6 #> #> [[4]] #> [1] 7 8 #>