Concatenating Matrices in R

前端 未结 2 953
说谎
说谎 2021-01-07 15:51

How can I concatenate matrices of same columns but different number of rows? For example, I want to concatenate a ( dim(a) = 15 7000 ) and b (dim(b) = 16

2条回答
  •  青春惊慌失措
    2021-01-07 16:48

    Sounds like you're looking for rbind:

    > a<-matrix(nrow=10,ncol=5)
    > b<-matrix(nrow=20,ncol=5)
    > dim(rbind(a,b))
    [1] 30  5
    

    Similarly, cbind stacks the matrices horizontally.

    I am not entirely sure what you mean by the last question ("Can I do this for matrices of different rows and columns.?")

提交回复
热议问题