[R] Binding a matrix to a matrix

Bert Gunter gunter.berton at gene.com
Tue Mar 2 23:55:20 CET 2010


Because you're binding on the last dimension, the default ordering of arrays
will do the job for you, so that the following works without abind():

## a1 is your 2 x 10 x 200 array
## m1 is your 2 x 10 matrix.

## Then the 2 x 10 x 201 array your want (note the 2001 typo in your note )
is:

NewArray <- array(c(a1,m1),dim=c(2,10,201))

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Rolf Turner
Sent: Tuesday, March 02, 2010 2:33 PM
To: Luis Felipe Parra
Cc: r-help at r-project.org
Subject: Re: [R] Binding a matrix to a matrix


On 3/03/2010, at 11:22 AM, Luis Felipe Parra wrote:

> Hello I have a 2x10x200 matrix and I would like to bind to it another 2x10
> matrix in order to end up with an 2x10x2001 matrix, which command should i
> use in order to do this? Thank you

(a) It's not a ***matrix***.  Matrices are ***two*** dimensional.  It's an
array.

(b) Use abind() from the abind package.

(c) RSiteSearch("bind arrays") would have led you straight to this ....
but just RSiteSearch("bind") makes it the 57-th item so you probably
wouldn't have found it that way.

	cheers,

		Rolf Turner


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

______________________________________________
R-help at 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.



More information about the R-help mailing list