Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not known in advance) number of dimensions. How do you deal with
these situations?
It appears that it is not possible use a list as an index, for
instance this fails:
x - array(NA, c(2,2,2))
x[list(TRUE,TRUE,2)]
Error
On 02/11/11 11:14, Ernest Adrogué wrote:
Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not known in advance) number of dimensions. How do you deal with
these situations?
It appears that it is not possible use a list as an index, for
instance this fails:
x-
Leaving the indices empty should give you what I'm guessing you want/expect.
x[,,2]#. TRUE would also work, just not in a list.
David.
On Nov 1, 2011, at 6:14 PM, Ernest Adrogué nfdi...@gmail.com wrote:
Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not
Yes,Ii did fail to read your post carefully and agree do.call seems
roundabout, but alternatives look even more tortured.
(You might want to include more context in the future.)
On Nov 1, 2011, at 8:30 PM, Ernest Adrogué eadro...@gmx.net wrote:
1/11/11 @ 20:22 (-0400), Comcast escriu:
Here's a hack, but perhaps you might want to rethink what type of
output you want.
# Function:
g - function(arr, lastSubscript = 1) {
n - length(dim(arr))
commas - paste(rep(',', n - 1), collapse = '')
.call - paste('arr[', commas, lastSubscript, ']', sep = '')
eval(parse(text =
1/11/11 @ 20:22 (-0400), Comcast escriu:
Leaving the indices empty should give you what I'm guessing you want/expect.
x[,,2]#. TRUE would also work, just not in a list.
Exactly, but this only works if x has three dimensions. What I want is
x[,,2] if x has three dimensions, x[,,,2] if it
2/11/11 @ 13:10 (+1300), Rolf Turner escriu:
On 02/11/11 11:14, Ernest Adrogué wrote:
Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not known in advance) number of dimensions. How do you deal with
these situations?
It appears that it is not possible use a list
On 02/11/11 13:43, Ernest Adrogué wrote:
SNIP
Sorry for not stating my problem in a more clear way. What I want is,
given an array of n dimensions, overwrite it by iteratating over its
outermost dimension... OK, in the previous example, I would like
to do
x- array(NA, c(2,2,2))
for (i in 1:2)
2011/11/1 Ernest Adrogué nfdi...@gmail.com:
Hi,
On ocasion, you need to subscript an array that has an arbitrary
(ie. not known in advance) number of dimensions. How do you deal with
these situations?
It appears that it is not possible use a list as an index, for
instance this fails:
x -
9 matches
Mail list logo