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

as.which

Coercion to (positive) integer positions


Description

Coercing to something like the result of which which

Usage

## S3 method for class 'which'
as.which(x, maxindex = NA_integer_, ...)

## S3 method for class ''NULL''
as.which(x, ...)

## S3 method for class 'numeric'
as.which(x, maxindex = NA_integer_, ...)

## S3 method for class 'integer'
as.which(x, maxindex = NA_integer_, is.unsorted = TRUE, has.dup = TRUE, ...)

## S3 method for class 'logical'
as.which(x, ...)

## S3 method for class 'ri'
as.which(x, ...)

## S3 method for class 'bit'
as.which(x, range = NULL, ...)

## S3 method for class 'bitwhich'
as.which(x, ...)

as.which(x, ...)

Arguments

x

an object of classes bit, bitwhich, ri or something on which which works

maxindex

the length of the boolean vector which is represented

...

further arguments (passed to which for the default method, ignored otherwise)

is.unsorted

a logical scalar indicating whether the data may be unsorted

has.dup

a logical scalar indicating whether the data may have duplicates

range

a ri or an integer vector of length==2 giving a range restriction for chunked processing

Details

as.which.bit returns a vector of subscripts with class 'which'

Value

a vector of class 'logical' or 'integer'

Methods (by class)

Author(s)

Jens Oehlschlägel

See Also

Examples

r <- ri(5, 20, 100)
  x <- as.which(r)
  x

  stopifnot(identical(x, as.which(as.logical(r))))
  stopifnot(identical(x, as.which(as.bitwhich(r))))
  stopifnot(identical(x, as.which(as.bit(r))))

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.