[R] array

Roland Rau roland.rproject at gmail.com
Tue Aug 7 21:48:12 CEST 2007


Hi,

Tiandao Li wrote:
> Hello,
> 
> I have some files generated from microarray experiments. I used scan() to
> read the files, and assigned each file to a unique name with many rows and
> columns. Now I want to create a array (ArrayA) with unique names, and I can
> use ArrayA[1,2][[6]] to refer the data in each file. Is there any packages
> available for array of array?
> 
if all of your initial arrays only consist of rows and columns
(i.e. matrices) and have the same number of rows and columns, you can
store it conveniently in a three dimensional array:

mat1a <- matrix(1:10, ncol=2)
mat2a <- matrix(11:20, ncol=2)
mat1a
mat2a

arr3D <- array(numeric(0), dim=c(nrow(mat1a), ncol(mat1a), 2))
arr3D[,,1] <- mat1a
arr3D[,,2] <- mat2a

arr3D
arr3D[,,2]

if your initial arrays (assuming again that you have matrices) have
varying amount of rows and columns, I would suggest to use lists:

mat1b <- matrix(1:10, ncol=2)
mat2b <- matrix(101:133, ncol=3)
mat1b
mat2b
list3D <- list(numberone=mat1b, numbertwo=mat2b)
list3D

list3D[[1]]
list3D[[1]]
list3D[["numberone"]]
list3D[["numbertwo"]]


I hope this helps.

Best,
Roland



More information about the R-help mailing list