假设我有一个矩阵:
每三列输出一次。
M = diag(6)
and I want to insert
d = rep(5,6)
每三列输出一次。
M
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 0 0 0 0 0
[2,] 0 1 0 0 0 0
[3,] 0 0 1 0 0 0
[4,] 0 0 0 1 0 0
[5,] 0 0 0 0 1 0
[6,] 0 0 0 0 0 1
> d
[1] 5 5 5 5 5 5
输出:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 0 0 5 0 0 0 5
[2,] 0 1 0 5 0 0 0 5
[3,] 0 0 1 5 0 0 0 5
[4,] 0 0 0 5 1 0 0 5
[5,] 0 0 0 5 0 1 0 5
[6,] 0 0 0 5 0 0 1 5