Re: [Rd] array extraction

2011-09-27 Thread Ted Harding
Somewhat out of my depth here (I have only 2 arms, but am swimming in waters which require 3): My interpretation is that a and M are basically vectors, with dimension attributes, accessed down the columns. The array 'a' consists of 30 elements 1:30 in that order, accessed by each of 3 rows for eac

Re: [Rd] array extraction

2011-09-27 Thread robin hankin
thank you Simon. I find a[M] working to be unexpected, but consistent with (a close reading of) Extract.Rd Can we reproduce a[,M]? [I would expect this to extract a[,j,k] where M[j,k] is TRUE] try this: > a <- array(1:30,c(3,5,2)) > M <- matrix(1:10,5,2) %% 3==1 > a[M] [1] 1 4 7 10 11 14

Re: [Rd] array extraction

2011-09-27 Thread Simon Knapp
a[M] gives the same as your `cobbled together' code. On Wed, Sep 28, 2011 at 6:35 AM, robin hankin wrote: > hello everyone. > > Look at the following R idiom: > > a <- array(1:30,c(3,5,2)) > M <- (matrix(1:15,c(3,5)) %% 4) < 2 > a[M,] <- 0 > > Now, I think that "a[M,]" has an unambiguous meani

[Rd] array extraction

2011-09-27 Thread robin hankin
hello everyone. Look at the following R idiom: a <- array(1:30,c(3,5,2)) M <- (matrix(1:15,c(3,5)) %% 4) < 2 a[M,] <- 0 Now, I think that "a[M,]" has an unambiguous meaning (to a human). However, the last line doesn't work as desired, but I expected it to...and it recently took me an indecent