I wonder if there could be some reason for this default behavior? If there are any agreed upon quirks that I would love to know about.
Below are two different queries (resulting in a length of 20 and 0), but I expect that they will have the same behavior regarding removing redundant measurements. The subset, NULLfor some reason, preserves an empty dimension. ?drop:
Delete array sizes that have only one level.
What is the save point of 0 level measurements with drop=TRUE?
I am developing a class similar to an array, and because of this I hit inconsistency with base::array. Should I report such a problem on the R dev platform?
set.seed(1L)
ar.dimnames = list(color = sort(c("green","yellow","red")),
year = as.character(2011:2015),
status = sort(c("active","inactive","archived","removed")))
ar.dim = sapply(ar.dimnames, length)
ar = array(sample(c(rep(NA, 4), 4:7/2), prod(ar.dim), TRUE),
unname(ar.dim),
ar.dimnames)
r1 = ar["green",,,drop=TRUE]
dimnames(r1)
#$year
#[1] "2011" "2012" "2013" "2014" "2015"
#
#$status
#[1] "active" "archived" "inactive" "removed"
#
length(r1)
#[1] 20
r2 = ar[NULL,,,drop=TRUE]
dimnames(r2)
#$color
#NULL
#
#$year
#[1] "2011" "2012" "2013" "2014" "2015"
#
#$status
#[1] "active" "archived" "inactive" "removed"
#
length(r2)
#[1] 0