Às 17:33 de 29/09/2023, Joseph Wood escreveu:
Hello,
I recently discovered a possible inconsistency with usage of an object of
class array.
Consider the following example:
## Setup
a <- array(1:6, dim = c(1, 3, 2))
a
, , 1
[,1] [,2] [,3]
[1,]123
, , 2
[,1] [,2] [,3]
Hi Joseph
This behaviour is as expected (and as documented by ?`[`) because the default
of drop=TRUE coerces the result to the lowest possible dimension, which in your
case is a vector rather than array. Using for example:
b[1,,,drop=FALSE]
... results in an output array with the same number
This is due to `[` dropping dimensions by default. In your first
example, think of a[1, , ] as having dimension c(1, 3, 2), but,
because drop = TRUE, all dimensions of extent 1 (the first dimension)
are dropped and the result has dimension c(3, 2). In your second
example, b[1, , ] would have dimens
Hello,
I recently discovered a possible inconsistency with usage of an object of
class array.
Consider the following example:
## Setup
a <- array(1:6, dim = c(1, 3, 2))
a
, , 1
[,1] [,2] [,3]
[1,]123
, , 2
[,1] [,2] [,3]
[1,]456
class(a)
[1] "array"
dim(a)