split_vector: Splits a vector into list of vectors by 'chunk' or 'size'

Description Usage Arguments Details Value Examples

View source: R/accessory_funcs.R

Description

Splits a vector into list of vectors by chunk or size

Usage

1
split_vector(vec, chunks = NA, percent = NA, size = NA)

Arguments

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

Details

Splits a vector into consistantly sized sub-lists. The sub-list size will always be decreasing based on list order.

Value

A list of sub-vectors

Examples

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)

CompEpigen/scMethrix documentation built on Nov. 6, 2021, 3:09 p.m.