anyOutside {hutilscpp} | R Documentation |
Are any values outside the interval specified?
Description
Are any values outside the interval specified?
Usage
anyOutside(x, a, b, nas_absent = NA, na_is_outside = NA)
Arguments
x |
A numeric vector. |
a , b |
Single numeric values designating the interval. |
nas_absent |
Are If |
na_is_outside |
(logical, default:
#'
|
Value
0L
if no values in x
are outside [a, b]
. Otherwise, the position
of the first value of x
outside [a, b]
.
Examples
anyOutside(1:10, 1L, 10L)
anyOutside(1:10, 1L, 7L)
# na_is_outside = NA
anyOutside(c(1:10, NA), 1L, 7L) # Already outside before the NA
anyOutside(c(NA, 1:10, NA), 1L, 7L) # NA since it occurred first
anyOutside(c(1:7, NA), 1L, 7L, na_is_outside = FALSE)
anyOutside(c(1:7, NA), 1L, 7L, na_is_outside = TRUE)
##
# N <- 500e6
N <- 500e3
x <- rep_len(hutils::samp(-5:6, size = 23), N)
bench_system_time(anyOutside(x, -5L, 6L))
# process real
# 453.125ms 459.758ms