Change matrix dimension

前端 未结 5 1639
离开以前
离开以前 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:32

    We can do this directly

    do.call(rbind,lapply(1:ncol(d),function(t) matrix(d[,t],ncol = 4)))
    

提交回复
热议问题