[R] How to join two matrices?

Jorge Ivan Velez
2009-09-04T22:34:08Z

Hi Peng,
Try

rbind(x,y)
cbind(x,y)

HTH,
Jorge

On Fri, Sep 4, 2009 at 6:26 PM, Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> Suppose I have the following two matrices.
> > x=matrix(1:4,nr=2)
> > y=matrix(5:8,nr=2)
>
> I want to join the two matrices to get the following two new matrices.
> I did a search but I don't find any relevant webpage. Can somebody let
> me know how to do it?
>
>     [,1] [,2]
> [1,]    1    3
> [2,]    2    4
> [3,]    5    7
> [4,]    6    8
>
>     [,1] [,2] [,3] [,4]
> [1,]    1    3    5    7
> [2,]    2    4    6    8
>
> Regards,
> Peng
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]