[R] rbind to array members

Another Oneforyou anotheroneforyou at hotmail.com
Mon Oct 19 20:59:22 CEST 2009


 <4ADBCA02.8020101 at temple.edu>
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0


>=20
> library(abind)  ## array binding

I've looked into using abind()=2C but it seems I might not understand it pr=
operly.

I can build my 2 table array=2C and insert a row into each table using:

=A0=A0=A0=A0=A0=A0=A0 x <- array(0=2Cc(1=2C3=2C2))

=A0=A0=A0=A0=A0=A0=A0 x[=2C=2C1] <- c(1=2C2=2C3)

=A0=A0=A0=A0=A0=A0=A0 x[=2C=2C2] <- c(7=2C8=2C9)


And I can use rbind() or abind() to add a row to the first table and assign=
 it to a separate object.

=A0=A0=A0=A0=A0=A0=A0 y <- rbind(x[=2C=2C1]=2C c(4=2C5=2C6))

=A0=A0=A0=A0=A0=A0=A0 z <- abind(x[=2C=2C1]=2C c(4=2C5=2C6)=2Calong=3D0)


But I can't determine how to add a row in place to a single table of the 3 =
dimensional array. For example=2C this does not work:

=A0=A0=A0=A0=A0=A0=A0 x[=2C=2C1] <- abind(x[=2C=2C1]=2C c(4=2C5=2C6)=2Calon=
g=3D0)

Error in x[=2C =2C 1] <- abind(x[=2C =2C 1]=2C c(4=2C 5=2C 6)=2C along =3D =
0) :=20
=A0 number of items to replace is not a multiple of replacement length


I would like 'x' to be:

> x

=2C =2C 1

=A0=A0=A0=A0 [=2C1] [=2C2] [=2C3]

[1=2C]=A0=A0=A0 1=A0=A0=A0 2=A0=A0=A0 3

[2=2C]=A0=A0=A0 4=A0=A0=A0 5=A0=A0=A0 6

=2C =2C 2

=A0=A0=A0=A0 [=2C1] [=2C2] [=2C3]

[1=2C]=A0=A0=A0 7=A0=A0=A0 8=A0=A0=A0 9




Thanks for any help.
 		 	   		 =20
_________________________________________________________________
Hotmail: Trusted email with Microsoft=92s powerful SPAM protection.




More information about the R-help mailing list