Søren Højsgaard
2008-Aug-20 23:16 UTC
[R] Extracting eg A[, , 3, 1, ] from an array but using dimension names and levels
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
Gabor Grothendieck
2008-Aug-21 00:03 UTC
[R] Extracting eg A[, , 3, 1, ] from an array but using dimension names and levels
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. >