how to combine 60 matrices in R quickly

后端 未结 3 974
时光说笑
时光说笑 2021-01-15 05:31

I have 60 matrices in R named as mat1, mat2....mat60 and I would like to combine them into a big matrix using rbind. I know that I could write something like



        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-15 06:11

    I think this question really relates to the OP having to type out the names of the matrices manually. You can use mget to return the matrices in a list and then use do.call and rbind as posed by @Michele like this (assuming the matrices are located in the .GlobalEnv ):

    matList <- mget(paste0("mat",1:60),env=globalenv())
    bigm <- do.call("rbind" , matList)
    

提交回复
热议问题