R/split_vector_into_chunks.R

Defines functions split_vector_into_chunks

Documented in split_vector_into_chunks

#' Split vector into chunks
#' 
#' NOTE: The output chunks may not be of equal size, as any reminder of elements will be part of last chunk. 
#' 
#' @param vec Vector of any type.
#' @param n Integer of desired count of chunks.
#' @return List of vector-split chunks.
#' @export 


split_vector_into_chunks = function(vec,n) {
  split(vec, ceiling(seq_along(vec)/(length(vec)/n)))
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.