runlengths | R Documentation |

Computes runlengths of an univariate `"timeSeries"`

object.

```
runlengths(x, ...)
```

`x` |
an univariate time series of class |

`...` |
arguments passed to the function |

Runlengths are defined here as contiguous sequences of values having the same sign.

Zeroes are treated as `NA`

s.

an object of class `"timeSeries"`

```
## 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.