View source: R/Analyses_functions_2.R
long_streak | R Documentation |
Computes the time span of the longest increasing or decreasing streak(s) of a time series for the provided time interval or its sub-interval.
long_streak(X, direction = "increasing", subI = NULL, plot = FALSE)
X |
Data frame where the first column is a numeric time sequence |
direction |
A character string which specifies the direction of
the streak: |
subI |
Time sub-interval is a vector, where the lower bound is the first element and the upper bound is the second. Optional: If provided longest streak(s) time span of the sub-interval is returned, otherwise the whole time interval is considered. |
plot |
Logical: If |
A data frame with one row for each longest streak, containing the time span
and the corresponding values of X(t)
at the streak endpoints.
mean_streak
t <- seq(0, 1, length = 100)
TS <- data.frame("t" = t,"X(t)" = rnorm(100))
long_streak(TS, direction = 'decreasing', subI = c(0.2, 0.8), plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.