## random time series -
set.seed(4711)
x <- rnorm(12)
tS <- timeSeries(data = x, charvec = timeCalendar(), units = "x")
tS
## return runlengths -
runlengths(tS)
## replace the middle value of the negative stretch of 3 values
tS[5] <- NA
## the two negative values separated by NA are still one run
runlengths(tS)
Run the code above in your browser using DataLab