R/get.first.peak.R

Defines functions get.first.peak

Documented in get.first.peak

#' Title
#'
#' @param curve
#'
#' @return
#' @export
#'
#' @examples
get.first.peak <- function(curve){
    # ver 3.4.1
    # get peak --> peak1
    if(!is.null(peak1 <- get.peak(curve))) {
        # get valley to the left --> valley1
        if(!is.null(valley <- get.valley(curve[ 1:peak1 ]))) {
            # -> has valley get peak to the left
            if(!is.null(peak2 <- get.peak(curve[ 1:valley ]))) {
                # -> has peak get first peak [1, valley.x]
                return(get.first.peak(curve[ 1:valley ]))
            } else {
                # -> no peak return peak1
                return(peak1)
            }
        } else {
            # -> no valley return peak1
            return(peak1)
        }
    } else {
        return(NULL)
    }
}
yanxianUCSB/yxhelper documentation built on April 20, 2020, 4:09 p.m.