R/split_matrix.R

Defines functions split_matrix

split_matrix = function(mat, n) {
	
	n.mat = nrow(mat)
	chunk.size = ceiling(n.mat / n)
	ix = c(seq(from=1, to=n.mat, by=chunk.size), n.mat+1) 
	
	mat.list = list()
	for(i in 1:n) {
		if(ix[i] > n.mat) break
		mat.list[[i]] = mat[ix[i]:(ix[i+1]-1),]
	}
	
	return(mat.list)
}

Try the SSNbler package in your browser

Any scripts or data that you put into this service are public.

SSNbler documentation built on Nov. 5, 2025, 7:38 p.m.