1findPeaks <- 2function(x, thresh=0) { 3 pks <- which(diff(sign(diff(x, na.pad=FALSE)),na.pad=FALSE) < 0) + 2 4 if( !missing(thresh) ) { 5 if(sign(thresh) < 0) 6 thresh <- -thresh 7 pks[x[pks-1]-coredata(x[pks]) > thresh] 8 } else pks 9} 10 11peak <- function(x) { 12 .Deprecated("findPeaks", package="quantmod") 13 findPeaks(x) 14} 15 16findValleys <- 17function(x, thresh=0) { 18 pks <- which(diff(sign(diff(x, na.pad=FALSE)),na.pad=FALSE) > 0) + 2 19 if( !missing(thresh) ) { 20 if(sign(thresh) > 0) 21 thresh <- -thresh 22 pks[x[pks-1]-coredata(x[pks]) < thresh] 23 } else pks 24} 25 26valley <- function(x) { 27 .Deprecated("findValleys", package="quantmod") 28 findValleys(x) 29} 30