Say I have the following matrix mat, which is a binary indicator matrix:
mat<-matrix(c(1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1), byrow=T, nrow=3)
> mat
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 1 0 0 0 0
[2,] 0 0 1 1 0 0
[3,] 0 0 0 0 1 1
This matrix has only 3 rows. I need to create one with 10000 rows, with the same pattern of pairs of 1s on the diagonals. E.g. for 5 rows, I expect a 5 x 10 matrix:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 1 0 0 0 0 0 0 0 0
[2,] 0 0 1 1 0 0 0 0 0 0
[3,] 0 0 0 0 1 1 0 0 0 0
[4,] 0 0 0 0 0 0 1 1 0 0
[5,] 0 0 0 0 0 0 0 0 1 1
Does anyone know a simple way to do that? Thanks a lot