R/rvminmax.R

rvminmax <- function (x, na.rm=FALSE, finite=FALSE, defaults=c(-Inf,Inf)) {
  ## NOEXPORT
  .minmax <- function (x, FUN, def) {
    if (na.rm) x <- x[!is.na(x)]
    if (finite) x <- x[is.finite(x)]
    if (length(x)==0) def else FUN(x)
  }
  m0 <- rvsimapply(x, .minmax, min, defaults[1])
  m1 <- rvsimapply(x, .minmax, max, defaults[2])
  list(min=m0, max=m1)
}

Try the rv package in your browser

Any scripts or data that you put into this service are public.

rv documentation built on March 18, 2022, 5:55 p.m.