R/first_which.R

Defines functions last_which first_which

first_which <- function(expr) {
  o <- which(expr)
  if (length(o)) {
    return(o[1])
  } else {
    return(0L)
  }
}

last_which <- function(expr) {
  o <- which(expr)
  if (length(o)) {
    return(last(o))
  } else {
    return(0L)
  }
}

Try the hutilscpp package in your browser

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

hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.