range_rcpp | R Documentation |
Range of a vector using Rcpp.
range_rcpp(
x,
anyNAx = anyNA(x),
warn_empty = TRUE,
integer0_range_is_integer = FALSE
)
x |
A vector for which the range is desired. Vectors with missing values are not supported and have no definite behaviour. |
anyNAx |
(logical, default: |
warn_empty |
(logical, default: |
integer0_range_is_integer |
(logical, default: |
A length-4 vector, the first two positions give the range and
the next two give the positions in x
where the max and min occurred.
This is almost equivalent to c(range(x), which.min(x), which.max(x))
.
Note that the type is not strictly preserved, but no loss should occur. In particular,
logical x
results in an integer result, and a double x
will
have double values for which.min(x)
and which.max(x)
.
A completely empty, logical x
returns c(NA, NA, NA, NA)
as an integer vector.
x <- rnorm(1e3) # Not noticeable at this scale
bench_system_time(range_rcpp(x))
bench_system_time(range(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.