Learn R Programming

bit (version 4.5.0.1)

maxindex.default: Get maxindex (length of boolean vector) and poslength (number of 'selected' elements)

Description

For is.booltype objects the term length is ambiguous. For example the length of which corresponds to the sum of logical. The generic maxindex gives length(logical) for all booltypes. The generic poslength gives the number of positively selected elements, i.e. sum(logical) for all booltypes (and gives NA if NAs are present).

Usage

# S3 method for default
maxindex(x, ...)

# S3 method for default poslength(x, ...)

# S3 method for logical maxindex(x, ...)

# S3 method for logical poslength(x, ...)

# S3 method for bit maxindex(x, ...)

# S3 method for bit poslength(x, ...)

# S3 method for bitwhich maxindex(x, ...)

# S3 method for bitwhich poslength(x, ...)

# S3 method for which maxindex(x, ...)

# S3 method for which poslength(x, ...)

# S3 method for ri maxindex(x, ...)

# S3 method for ri poslength(x, ...)

maxindex(x, ...)

poslength(x, ...)

Value

an integer scalar

Arguments

x

an R object, typically a is.booltype object.

...

further arguments (ignored)

Methods (by class)

  • maxindex(default): default method for maxindex

  • maxindex(logical): maxindex method for class logical

  • maxindex(bit): maxindex method for class bit

  • maxindex(bitwhich): maxindex method for class bitwhich

  • maxindex(which): maxindex method for class which

  • maxindex(ri): maxindex method for class ri

Functions

  • poslength(default): default method for poslength

  • poslength(logical): poslength method for class logical

  • poslength(bit): poslength method for class bit

  • poslength(bitwhich): poslength method for class bitwhich

  • poslength(which): poslength method for class which

  • poslength(ri): poslength method for class ri

Examples

Run this code
r <- ri(1,2,12)
i <- as.which(r)
w <- as.bitwhich(r)
b <- as.bit(r)
l <- as.logical(r)
u <- which(l)      # unclassed which

sapply(list(r=r,u=u,i=i,w=w,b=b,l=l), function(x){
  c(length=length(x), sum=sum(x), maxindex=maxindex(x), poslength=poslength(x))
})

Run the code above in your browser using DataLab