Re: [Rd] arraytake for extracting subarrays from multidimensional arrays

2006-10-19 Thread Balaji S. Srinivasan
If you can add it to the magic package, that would be great. It seems like the appropriate place for it. It would probably be useful to combine that with the adrop function or apldrop function in order to allow transparent extraction of subarrays. Perhaps the default could be "drop=FALSE" (please!

Re: [Rd] arraytake for extracting subarrays from multidimensional arrays

2006-10-19 Thread Robin Hankin
On 19 Oct 2006, at 14:26, Gabor Grothendieck wrote: > Note that it can also be done like with do.call: > > a <- array(1:24, 2:4) > L <- list(TRUE, 1:3, c(4, 2)) > do.call("[", c(list(a), L)) > aargggh, you beat me to it. I didn't think to pass TRUE to "[" . I'll stick it in the package wit

Re: [Rd] arraytake for extracting subarrays from multidimensional arrays

2006-10-19 Thread Gabor Grothendieck
Note that it can also be done like with do.call: a <- array(1:24, 2:4) L <- list(TRUE, 1:3, c(4, 2)) do.call("[", c(list(a), L)) On 10/19/06, Balaji S. Srinivasan <[EMAIL PROTECTED]> wrote: > Hi, > > I recently encountered a problem with array subsetting and came up with a > fix. Given an array o

Re: [Rd] arraytake for extracting subarrays from multidimensional arrays

2006-10-19 Thread Robin Hankin
Hi Your arraytake() function does indeed do something that can't be done elegantly by apltake(), AFAICS I think that arraytake() would make a splendid addition to the magic package. Would that be acceptable? best wishes rksh [I can't help thinking that a judicious use of do.call() could rep

[Rd] arraytake for extracting subarrays from multidimensional arrays

2006-10-19 Thread Balaji S. Srinivasan
Hi, I recently encountered a problem with array subsetting and came up with a fix. Given an array of arbitrary dimensions, in which the number of dimensions is only known at runtime, I wanted to extract a subarray. The main issue with doing this is that in order to extract a subarray from an array