README.md

tst - Timestamped Suffix Trees

lifecycle AppVeyor build
status Travis build
status Coverage
status

tst is an R package for building timestamped suffix trees (TSTs). TSTs are suffix trees that store timestamps for each state transition in the training sequence(s). Given a sequence of consecutive symbols, the TST can efficiently return the timepoints when this sequence occurred in the training data, the symbols that followed this sequence in the training data, and the timepoints when these continuation symbols were observed.

Installation

install.packages("devtools") # if you don't have devtools already installed
devtools::install_github("pmcharrison/tst")

Example use

library(tst)

# Build and visualize a simple suffix tree
t <- new_tree()
add_seq(t, c("a", "b", "c", "a", "b"))
#> A temporal suffix tree
#>   - number of stored symbols (inc. terminals) = 6
#>   - order bound = none
#>   - active order = 6
plot(t)


# Incrementally visualize the building of a suffix tree
t <- new_tree()
add_seq(t, c("a", "b", "c", "a", "b"), visual = TRUE)
#> Press enter to continue:
#> Press enter to continue:
#> Press enter to continue:
#> Press enter to continue:
#> Press enter to continue:
#> A temporal suffix tree
#>   - number of stored symbols (inc. terminals) = 6
#>   - order bound = none
#>   - active order = 6

# Search for n-grams
when_ngram(t, c("a", "b"))
#> # A tibble: 2 x 2
#>     pos  time
#>   <int> <dbl>
#> 1     2     1
#> 2     5     4
count_ngram(t, c("a", "b"))
#> [1] 2


pmcharrison/tst documentation built on May 24, 2019, 7:36 a.m.