Change matrix dimension

前端 未结 5 1635
离开以前
离开以前 2021-01-20 22:31

Let\'s make a replicable example:

This is my initial matrix

d<- matrix(1:80,,5)
d
     [,1] [,2] [,3] [,4] [,5]
[1,]    1   17   33   49   65
[2,         


        
5条回答
  •  隐瞒了意图╮
    2021-01-20 23:27

    Another simple solution:

    matrix <- matrix(seq(1,16), ncol = 4)
    rbind(matrix, 
          16+matrix, 
          32+matrix, 
          48+matrix, 
          64+matrix)
    

    or:

    matrix <- matrix(seq(1,16), ncol = 4)
    do.call(rbind, lapply(0:4, function(x){
        16*x+matrix
      })
    )
    

提交回复
热议问题