Specific methods for booltype are required, where non-unary methods can combine multiple bollean types, particularly boolean binary operators.

booltype(x)

Arguments

x

an R object

Value

one scalar element of booltypes() in case of 'nobool' it carries a name attribute with the data type.

Details

Function booltype returns the boolean type of its argument. There are currently six boolean types, booltypes is an ordered() vector with the following ordinal levels():

  • nobool: non-boolean type

  • logical(): for representing any boolean data including NA

  • bit(): for representing dense boolean data

  • bitwhich(): for representing sparse (skewed) boolean data

  • which(): for representing sparse boolean data with few `TRUE

  • ri(): range-indexing, for representing sparse boolean data with a single range of TRUE

Note

do not rely on the internal integer codes of these levels, we might add-in hi later

Examples

unname(booltypes)
#> [1] nobool   logical  bit      bitwhich which    ri      
#> Levels: nobool < logical < bit < bitwhich < which < ri
str(booltypes)
#>  Ord.factor w/ 6 levels "nobool"<"logical"<..: 1 2 3 4 5 6
#>  - attr(*, "names")= chr [1:6] "nobool" "logical" "bit" "bitwhich" ...
sapply(
  list(double(), integer(), logical(), bit(), bitwhich(), as.which(), ri(1, 2, 3)),
  booltype
)
#>   double  integer                                              
#>   nobool   nobool  logical      bit bitwhich    which       ri 
#> Levels: nobool logical bit bitwhich which ri