Split a matrix by rows, based on either the number of rows per group or number of splits.
split_matrix(mat, rowspergroup = NULL, nsplits = NULL, shuffle = TRUE)
A matrix to be split.
Number of rows in a group.
Number of splits to make.
Should the splits be shuffled before returning?
A list of the splits of the matrix.
# NOT RUN { mat <- matrix(1:12, ncol=2) split_matrix(mat, 4, shuffle=FALSE) split_matrix(mat, 4, shuffle=TRUE) split_matrix(mat, nsplits=3, shuffle=FALSE) # same as 4 rowspergroup # }
Run the code above in your browser using DataLab