Fast aggregation functions for booltype
vectors. namely bit
, all
, any
, anyNA
,
min
, max
, range
,
sum
and summary
.
Now all boolean summaries (except for anyNA
because the generic does not allow it) have an optional range
argument to restrict the range of evalution.
Note that the boolean summaries have meaning and return values differing from logical aggregation functions: they treat NA
as FALSE
,
min
, max
and range
give the minimum and maximum positions of TRUE
, summary
returns counts of FALSE
, TRUE
and the range
.
Note that you can force the boolean interpretation by calling the booltype method explicitely on any booltypes
input, e.g. min.booltype()
, see the examples.
# S3 method for bit
all(x, range = NULL, ...)# S3 method for bit
any(x, range = NULL, ...)
# S3 method for bit
anyNA(x, recursive = FALSE)
# S3 method for bit
sum(x, range = NULL, ...)
# S3 method for bit
min(x, range = NULL, ...)
# S3 method for bit
max(x, range = NULL, ...)
# S3 method for bit
range(x, range = NULL, ...)
# S3 method for bit
summary(object, range = NULL, ...)
# S3 method for bitwhich
all(x, range = NULL, ...)
# S3 method for bitwhich
any(x, range = NULL, ...)
# S3 method for bitwhich
anyNA(x, recursive = FALSE)
# S3 method for bitwhich
sum(x, range = NULL, ...)
# S3 method for bitwhich
min(x, range = NULL, ...)
# S3 method for bitwhich
max(x, range = NULL, ...)
# S3 method for bitwhich
range(x, range = NULL, ...)
# S3 method for bitwhich
summary(object, range = NULL, ...)
# S3 method for which
all(x, range = NULL, ...)
# S3 method for which
any(x, range = NULL, ...)
# S3 method for which
anyNA(x, recursive = FALSE)
# S3 method for which
sum(x, range = NULL, ...)
# S3 method for which
min(x, range = NULL, ...)
# S3 method for which
max(x, range = NULL, ...)
# S3 method for which
range(x, range = NULL, ...)
# S3 method for which
summary(object, range = NULL, ...)
# S3 method for booltype
all(x, range = NULL, ...)
# S3 method for booltype
any(x, range = NULL, ...)
# S3 method for booltype
anyNA(x, ...)
# S3 method for booltype
sum(x, range = NULL, ...)
# S3 method for booltype
min(x, range = NULL, ...)
# S3 method for booltype
max(x, range = NULL, ...)
# S3 method for booltype
range(x, range = NULL, ...)
# S3 method for booltype
summary(object, range = NULL, ...)
# S3 method for ri
all(x, range = NULL, ...)
# S3 method for ri
any(x, range = NULL, ...)
# S3 method for ri
anyNA(x, recursive = FALSE)
# S3 method for ri
sum(x, ...)
# S3 method for ri
min(x, ...)
# S3 method for ri
max(x, ...)
# S3 method for ri
range(x, ...)
# S3 method for ri
summary(object, ...)
as expected
an object of class bit or bitwhich
a ri
or an integer vector of length==2 giving a
range restriction for chunked processing
formally required but not used
formally required but not used
an object of class bit
Jens Oehlschlägel
Summaries of bit
vectors are quite fast because we use a double loop that fixes each
word in a processor register. Furthermore we break out of looping as soon
as possible. Summaries of bitwhich
vectors are even faster, if the selection is very skewed.
l <- c(NA, FALSE, TRUE)
b <- as.bit(l)
all(l)
all(b)
all(b, range=c(3,3))
all.booltype(l, range=c(3,3))
min(l)
min(b)
sum(l)
sum(b)
summary(l)
summary(b)
summary.booltype(l)
Run the code above in your browser using DataLab