Extracting zero elements from a disord gives an empty object. But the resulting object "forgets" its class:
library("disordR")
#> Loading required package: Matrix
o <- disord(c("a","b","a","z","c"))
o %in% "a"
#> A disord object with hash cfa45e2d02a803b2bfa4e2157e5a6e1da7d71321 and elements
#> [1] TRUE FALSE TRUE FALSE FALSE
#> (in some order)
o %in% "y"
#> [1] FALSE FALSE FALSE FALSE FALSE
o[o %in% "a"]
#> [1] "a" "a"
o[o %in% "y"]
#> integer(0)
Above, we see that both o %in% "a" and o %in% "y" correctly return a logical disord object. But while o[o %in% "a"] correctly returns a character vector [here dropped], o[o %in% "y"] returns integer(0) and it should return character(0)
Extracting zero elements from a
disord
gives an empty object. But the resulting object "forgets" its class:Created on 2023-07-10 with reprex v2.0.2
Above, we see that both
o %in% "a"
ando %in% "y"
correctly return a logicaldisord
object. But whileo[o %in% "a"]
correctly returns a character vector [here dropped],o[o %in% "y"]
returnsinteger(0)
and it should returncharacter(0)