[R] accessing arrays

Wolfgang Raffelsberger wraff at titus.u-strasbg.fr
Wed Jan 3 18:49:34 CET 2007


Hi Lars,

in a 3-dim array you have 3 axes, day x, y and z (which I named 
xNo/xYes, yNo/yYes and zSmall/zBig)
to assign directly the labels use :

 > tab <- array(1:8, c(2, 2, 2),dimnames= list(c("xNo","xYes"), 
c("yNo","yYes"),c("zBig","zSmall")))
 > tab
, , zBig

     yNo yYes
xNo    1    3
xYes   2    4

, , zSmall

     yNo yYes
xNo    5    7
xYes   6    8

If you wanted to have an array allowing to capture xNo/xYes vs yNo/yYes 
AND zBig","zSmall" vs aaBig","aaSmall" you need to go one dimension 
higher .. but I'm not sure if this is really what you wanted.

Hope this helps,
Wolfgang

Lars Rohrschneider a écrit :
> Hi Wolfgang,
> thanks for your hint. But I am desperating. I have an 3 dim array of say 10matrices where every matrix has to stick an other label. I found no way todirect assign the labels.
> for example 
> tab <- array(1:8, c(2, 2, 2))dimnames(tab[,,1]) <- list(c("No","Yes"), c("No","Yes"))dimnames(tab[,,2]) <- list(c("big","small"), c("small","big"))
> should look like this, , 1
>     No YesNo   1   3Yes  2   4
> , , 2
>         big  smallsmall   5   7big     6   8
>
>
>
>
>
>
> Wolfgang Raffelsberger wrote:> > try this :> x <- > array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26]))> > Cheers,> Wolfgang> > downunder03 a écrit :>> hi all. how can i adress a array directly. for example i wanna give array>> 1>> other labels than array 2. How can I overcome this problem?>>>> ...this doesn't work>>>> tab <- array(1:8, c(2, 2, 2))>> dimnames(tab[,,1]) <- list(c("No","Yes"), c("No","Yes"),c("ARRAY1"))>> dimnames(tab[,,2]) <- list(c("big","small"),>> c("small","big"),c("ARRAY2"))>>>>>>>>   > > >  > > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > . . . . .> > Wolfgang Raffelsberger, PhD> Laboratoire de BioInformatique et Génomique Intégratives> IGBMC> 1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France> Tel (+33) 388 65 3314         Fax (+33) 388 65 3276> wolfgang.raffelsberger at igbmc.u-strasbg.fr> > ______________________________________________> R-help at stat.math.ethz.ch 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.> > 
> -- View this message in context: http://www.nabble.com/-R--accessing-arrays-tf2913929.html#a8144807Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________R-help at stat.math.ethz.ch mailing listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
>
>
>
>   


-- 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3314         Fax (+33) 388 65 3276
http://www-bio3d-igbmc.u-strasbg.fr/~wraff
wolfgang.raffelsberger at igbmc.u-strasbg.fr



More information about the R-help mailing list