as.bit {bit}R Documentation

Coercion to bit

Description

Coerces logical or bit to bit vector (and test for bit)

Usage

is.bit(x)
as.bit(x, ...)
## S3 method for class 'bit':
as.bit(x, ...)
## S3 method for class 'logical':
as.bit(x, ...)
## S3 method for class 'integer':
as.bit(x, ...)
## S3 method for class 'which':
as.bit(x, length, ...)

Arguments

x an object of class bit, logical or integer
length the length of the new bit vector
... further arguments

Details

Coercion to bit is quite fast because we use a double loop that fixes each word in a processor register

Value

is.bit returns FALSE or TRUE, as.bit returns a vector of class 'bit'

Note

Zero is coerced to FALSE, all other numbers including NA are coerced to TRUE. This differs from the NA-to-FALSE coercion in package ff and may change in the future.

Author(s)

Jens Oehlschlägel

See Also

bit, as.logical

Examples

  x <- as.bit(c(FALSE, NA, TRUE))
  is.bit(x)
  as.bit(x)
  as.bit.which(c(1,3,4), 12)

[Package bit version 1.0-1 Index]