Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Extract

Extract or replace part of an boolean vector


Description

Operators acting on bit or bitwhich objects to extract or replace parts.

Usage

## S3 method for class 'bit'
x[[i]]

## S3 replacement method for class 'bit'
x[[i]] <- value

## S3 method for class 'bit'
x[i]

## S3 replacement method for class 'bit'
x[i] <- value

## S3 method for class 'bitwhich'
x[[i]]

## S3 replacement method for class 'bitwhich'
x[[i]] <- value

## S3 method for class 'bitwhich'
x[i]

## S3 replacement method for class 'bitwhich'
x[i] <- value

Arguments

x

a bit or bitwhich object

i

preferrably a positive integer subscript or a ri, see text

value

new logical or integer values

Details

The typical usecase for for '[' and '[<-' is subscripting with positive integers, negative integers are allowed but slower, as logical subscripts only scalars are allowed. The subscript can be given as a bitwhich object. Also ri can be used as subscript.

Extracting from bit and bitwhich is faster than from logical if positive subscripts are used. integer subscripts make sense. Negative subscripts are converted to positive ones, beware the RAM consumption.

Value

The extractors [[ and [ return a logical scalar or vector. The replacment functions return an object of class(x).

Author(s)

Jens Oehlschlägel

See Also

Examples

x <- as.bit(c(FALSE, NA, TRUE))
  x[] <- c(FALSE, NA, TRUE)
  x[1:2]
  x[-3]
  x[ri(1,2)]
  x[as.bitwhich(c(TRUE,TRUE,FALSE))]
  x[[1]]
  x[] <- TRUE
  x[1:2] <- FALSE
  x[[1]] <- TRUE

bit

Classes and Methods for Fast Memory-Efficient Boolean Selections

v4.0.4
GPL-2 | GPL-3
Authors
Jens Oehlschlägel [aut, cre], Brian Ripley [ctb]
Initial release
2020-08-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.