Message-ID: <F99A7BAA16F00E4FB872978F3F99137803AF97C6@VFGAMLAO13.Enterprise.afmc.ds.af.mil>
Date: 2009-04-15T18:33:51Z
From: Cable, Samuel B Civ USAF AFMC AFRL/RVBXI
Subject: (hopefully) simple array op
In-Reply-To: <mailman.25.1239789606.8943.r-help@r-project.org>
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