Employs min()
and max()
. However, base::range()
, there is no argument
for removing Inf
values.
Examples
# \donttest{
x <- rep(1:1e5, 100)
system.time(rep(range(x), 100))
#> user system elapsed
#> 0.015 0.012 0.027
system.time(rep(range2(x), 100))
#> user system elapsed
#> 0.013 0.000 0.013
x[sample(x, 1e5)] <- NA
system.time(rep(range(x, na.rm = TRUE), 100))
#> user system elapsed
#> 0.307 0.024 0.331
system.time(rep(range2(x, na.rm = TRUE), 100))
#> user system elapsed
#> 0.013 0.000 0.013
# }