#' get peak position
#'
#' @param curve
#' @param x
#'
#' @return
#' @export
#'
#' @examples
get.peak <- function(curve, x = seq_along(curve)) {
#Ver 3.4.1
curve.max <- max(curve)
len = length(curve)
if (len == 1)
return (NULL)
if (curve.max == curve[len])
return(get.peak(curve[1:len - 1], x[1:len - 1]))
if (curve.max == curve[1])
return(get.peak(curve[2:len], x[2:len]))
return(x[which(curve == curve.max)])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.