Do you want abind?

http://cran.r-project.org/web/packages/abind/index.html

baptiste

On 15 Apr 2009, at 19:33, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI wrote:

I have a multidimensional array "a", for example,

a
, , 1

    [,1] [,2]
[1,]    1    3
[2,]    2    4

, , 2

    [,1] [,2]
[1,]    5    7
[2,]    6    8

So a is 2x2x2.

I have another array "b", for example,

b
    [,1] [,2]
[1,]    9   11
[2,]   10   12

So b is 2x2.

I want to "tack" b onto a so that b becomes a new "plane", so to speak,
in a.  In other words, I want the result c to be:

c
, , 1

    [,1] [,2]
[1,]    1    3
[2,]    2    4

, , 2

    [,1] [,2]
[1,]    5    7
[2,]    6    8

, , 3

    [,1] [,2]
[1,]    9   11
[2,]   10   12

I can think of a number of ways to do this, but they are all cumbersome.
Given R's facility with arrays and indices, it occurs to me that there
might be some "one-line" way to accomplish this.  Does anyone know if
there is?  Thanks.

--Sam

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

_____________________________

Baptiste AuguiƩ

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

Reply via email to