Jim,
Is
do.call( '[', list( array4d,TRUE,TRUE,TRUE,1 ) )
what you want?
HTH,
Chuck
On Fri, 12 Jun 2009, Jim Lemon wrote:
Hi all,
I've been trying to work out how to slice an array of arbitrary dimension. I
found a message showing how to stick two arrays together, but so far have
been unable to transform that into what I need. Assume that I have a four
dimensional array for example:
array4d
, , 1, 1
[,1] [,2]
[1,] 3 6
[2,] 1 1
, , 2, 1
[,1] [,2]
[1,] 4 7
[2,] 8 7
, , 1, 2
[,1] [,2]
[1,] 7 8
[2,] 8 7
, , 2, 2
[,1] [,2]
[1,] 7 5
[2,] 9 9
I want to slice the array from the rightmost dimension, getting in sequence:
array4d[,,,1]
array4d[,,,2]
then slicing those 3D arrays, and so on. I'm pretty sure that this will
involve a:
do.call('[',...)
construction, but I haven't been able to work out how to specify the list of
arguments, in particular the index vector, to slice up the last dimension. I
have tried constructing index vectors with NULLs which of course doesn't work
because they just disappear. Any suggestions?
Jim
______________________________________________
R-help@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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
______________________________________________
R-help@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.