Count of Sequential Events

Count the occurrence of sequences of values in a vector that meets certain conditions of length and magnitude. The method is based on the Run Length Encoding algorithm, available with base R, inspired by A. H. Robinson and C. Cherry (1967) .


nseq

R-CMD-check

Compute the number of sequences of values in a vector that meets conditions of length and magnitude.

Installation

You can install the development version of nseq from GitHub with:

# install.packages("remotes")
remotes::install_github("rfsaldanha/nseq")

Example

On this vector, how many sequences of values present at least 3 consecutive observations with values equal or greater than 5?

library(nseq)

vec <- c(8,15,20,8,1,7,8,0,-2,5,9,12,0,-1,4,2,3,1)

trle_cond(vec, a_op = "gte", a = 3, b_op = "gte", b = 5)
#> [1] 2

And how many sequences of values have exactly 3 consecutive observations with values equal or greater than 5?

trle_cond(vec, a_op = "e", a = 3, b_op = "gte", b = 5)
#> [1] 1

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("nseq")

0.1.1 by Raphael Saldanha, 2 years ago


https://rfsaldanha.github.io/nseq/


Report a bug at https://github.com/rfsaldanha/nseq/issues


Browse source code at https://github.com/cran/nseq


Authors: Raphael Saldanha [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports checkmate

Suggests testthat, ggplot2, dplyr


Imported by epidesc.


See at CRAN