[R] Extracting eg A[, , 3, 1, ] from an array but using dimension names and levels

Gabor Grothendieck ggrothendieck at gmail.com
Thu Aug 21 02:03:47 CEST 2008


Try this:

do.call("[", c(list(HairEyeColor), list(TRUE, 3, 1)))

On Wed, Aug 20, 2008 at 7:16 PM, Søren Højsgaard
<Soren.Hojsgaard at agrsci.dk> wrote:
> Consider the extraction
>
>> HairEyeColor[,3,1]
> Black Brown   Red Blond
>   10    25     7     5
>
> Suppose I have the appropriate dimensions and levels given as variables, e.g.
> d1 <-2
> l1 <-3
> d2 <-3
> l2 <-1
>
> How can I then make the "extraction" above using d1, l1, d2, l2  (for an array of arbitrary dimension)?
>
> Best regards
> Søren
>
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list