R/get.first.valley.R

Defines functions get.first.valley

Documented in get.first.valley

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