Some R code to detect peaks in time series data (modified from stack overflow)