HenrikBengtsson / listenv

R package: listenv - Environments Behaving As Lists
https://listenv.futureverse.org
30 stars 2 forks source link

Dimensions: Add aperm() for list environments? #28

Closed HenrikBengtsson closed 3 years ago

HenrikBengtsson commented 8 years ago

Currently,

> x <- as.list(1:6); dim(x) <- c(2,3)
> aperm(x, 2:1)
     [,1] [,2]
[1,] 1    2
[2,] 3    4
[3,] 5    6
> y <- as.listenv(x)
> aperm(y, 2:1)
Error in aperm.default(y, 2:1) : invalid first argument, must be an array
> is.array(y)
[1] TRUE

aperm() is a generic function, so should be possible to write one for list environments.

HenrikBengtsson commented 8 years ago

Shuffling around dimensions should be fairly cheap, because it would only require shuffling around elements in the internal variable map accordingly.