[R] How to join two matrices?

David Winsemius dwinsemius at comcast.net
Sat Sep 5 00:31:47 CEST 2009


On Sep 4, 2009, at 6:26 PM, Peng Yu 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

?rbind
>
>     [,1] [,2] [,3] [,4]
> [1,]    1    3    5    7
> [2,]    2    4    6    8

?cbind

These are pretty basic questions. What introductory documents are you  
working with that don't describe rbind and cbind at an early stage of  
matrix operations?

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list