Re: [R] How to join two matrices?

2009-09-04 Thread Jorge Ivan Velez
Hi Peng,
Try

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

HTH,
Jorge

On Fri, 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,]13
> [2,]24
> [3,]57
> [4,]68
>
> [,1] [,2] [,3] [,4]
> [1,]1357
> [2,]2468
>
> 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]]

__
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.


Re: [R] How to join two matrices?

2009-09-04 Thread David Winsemius


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,]13
[2,]24
[3,]57
[4,]68


?rbind


[,1] [,2] [,3] [,4]
[1,]1357
[2,]2468


?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

__
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.