DivideMat: Divide a matrix into N chunks of equal size

Description Usage Arguments Value Author(s) Examples

View source: R/PBOFun.R

Description

Split matrix M into equal chunks, where each chunk has the same number of columns and rows. For example, if the original matrix has 10 columns and 100 rows, and n=5, this function generates five matrices of size 20 x 10. Function returns a list of length n.

Usage

1
DivideMat(M, n)

Arguments

M

matrix with number of rows divisible by n

n

number of submatrices to break M into

Value

list of length n, where each element is a matrix.

Author(s)

Horace W. Tso horacetso@gmail.com

Examples

1
2
3
4
5
6
   N = 20 # no of strategies
   TT = 1000 # no of observations
   S = 20 # no of partitions
   M = matrix(rnorm(N*TT, mean=0.1, sd=1), ncol=N, nrow=TT)
   Ms = DivideMat(M, S)
   length(Ms)

htso/PBO documentation built on Jan. 31, 2020, 4:20 p.m.