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.
#' @author See: https://stackoverflow.com/questions/3318333/split-a-vector-into-chunks-in-r
#' @export 


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