Description Usage Arguments Details Value Examples
View source: R/accessory_funcs.R
Splits a vector into list of vectors by chunk
or size
1 | 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 |
Splits a vector into consistantly sized sub-lists. The sub-list size will always be decreasing based on list order.
A list of sub-vectors
1 2 3 4 5 6 7 8 | # Split vector into 4 sub vectors
split_vector(c(1,2,3,4,5,6,7,8),chunks=4)
# Split vector into sub-vectors with a size of 2
split_vector(c(1,2,3,4,5,6,7,8),size=2)
# 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.