Displaying 2 results from an estimated 2 matches for "apltake".
Did you mean:
apatare
2006 Oct 19
2
arraytake for extracting subarrays from multidimensional arrays
...is because I wanted to
do some toy problems involving conditioning on multiple variables in a
multidimensional joint pmf.)
I looked through commands like slice.index and so on, but they seemed to
require reshaping and big logical matrix intermediates, which were not
memory efficient enough for me. apltake in the magic package was the closest
but it only allowed subsetting of contiguous indices from either the first
or last element in any given dimension. It was certainly possible to call
apltake multiple times to extract arbitrary subarrays via combinations of
index intervals for each dimension, and...
2005 Nov 23
4
x[1,], x[1,,], x[1,,,], ...
Hi,
is there a function in R already doing what I try to do below:
# Let 'x' be an array with *any* number of dimensions (>=1).
x <- array(1:24, dim=c(2,2,3,2))
...
x <- array(1:24, dim=c(4,3,2))
i <- 2:3
ndim <- length(dim(x))
if (ndim == 1)
y <- x[i]
else if (ndim == 2)
y <- x[i,]
else if (ndim == 3)
y <- x[i,,]
else ...
and so on. My current