as.logical.bit {bit}R Documentation

Coercion from bit

Description

Coercing from bit to logical or integer

Usage

## S3 method for class 'bit':
as.logical(x, ...)
## S3 method for class 'bit':
as.integer(x, ...)
which(x, ...)
## Default S3 method:
which(x, arr.ind = FALSE, ...)
## S3 method for class 'bit':
which(x, negative = NA, ...)

Arguments

x an object of class bit
arr.ind see which
negative TRUE returns negative subscripts, FALSE returns positive subscripts, NA returns whatever requires less memory
... further arguments (formally required)

Details

as.logical.bit and as.integer.bit return a vector of FALSE, TRUE resp. 0,1. which.bit returns a vector of subscripts (which has been made generic). Coercion from bit is quite fast because we use a double loop that fixes each word in a processor register.

Value

a vector of class 'logical' or 'integer'

Author(s)

Jens Oehlschlägel

See Also

bit, as.bit, as.logical, as.integer, which

Examples

  x <- as.bit(c(FALSE, NA, TRUE, rep(TRUE, 9)))
  as.logical(x)
  as.integer(x)
  which.bit(x)
  which.bit(x, negative=TRUE)
  which.bit(x, negative=FALSE)

[Package bit version 1.0-1 Index]