R/localMaxima.fun.R

Defines functions localMaxima.fun

Documented in localMaxima.fun

#' Finds local maxima on peak traces
#'
#' @param z 
#'
#' @return 
#' @export
#'
#' @examples
#' test <- localMaxima(z)
#' 

localMaxima.fun <- function(z) {
  # Use -Inf instead if x is numeric (non-integer)
  y <- diff(c(-.Machine$integer.max, z)) > 0L
  rle(y)$lengths
  y <- cumsum(rle(y)$lengths)
  y <- y[seq.int(1L, length(y), 2L)]
  if (z[[1]] == z[[2]]) {
    y <- y[-1]
  }
  y
}
deftic/defShit documentation built on March 29, 2020, 11:10 a.m.