Just to be different, the premise was that you do not know how many dimensions
the array had. But that is easily available using dim() including how many
items are in each dimension. So, in principle, you can use a normal indexing
method perhaps in a loop to get what you want. Not sexy but doabl
Le 12/02/2021 à 23:49, Sokol Serguei a écrit :
Le 12/02/2021 à 22:23, Rui Barradas a écrit :
Hello,
Yes, although there is an accepted solution, I believe you should
post this solution there. It's a base R solution, what the question
asks for.
And thanks, I would have never reminded myself
Le 12/02/2021 à 22:23, Rui Barradas a écrit :
Hello,
Yes, although there is an accepted solution, I believe you should post
this solution there. It's a base R solution, what the question asks for.
And thanks, I would have never reminded myself of slice.index.
There is another approach -- pr
Hello,
Yes, although there is an accepted solution, I believe you should post
this solution there. It's a base R solution, what the question asks for.
And thanks, I would have never reminded myself of slice.index.
Rui Barradas
Às 20:45 de 12/02/21, robin hankin escreveu:
Rui
> x <- array(
Rui
> x <- array(runif(60), dim = c(10, 2, 3))
> array(x[slice.index(x,1) %in% 1:5],c(5,dim(x)[-1]))
(I don't see this on stackoverflow; should I post this there too?) Most of
the magic package is devoted to handling arrays of arbitrary dimensions and
this functionality might be good to include
Toby,
R provides more convenient ways for this - using window devices for any output
other than screen is not its intended function. I would recommend using the
off-screen devices devices such as pdf() or png() to generate output which also
gives you far more control. Also please note that the
Hello,
This came up in this StackOverflow post [1].
If x is an array with n dimensions, how to subset by just one dimension?
If n is known, it's simple, add the required number of commas in their
proper places.
But what if the user doesn't know the value of n?
The example below has n = 3, and