find_sequence | R Documentation |
This function checks whether the sequence ctx
is represented in the context
tree ct
. If this is the case, it returns a description of matching node, an
object of class ctx_node
. If the sequence is not represented in the tree,
the function return NULL
.
find_sequence(ct, ctx, reverse = FALSE, ...)
## S3 method for class 'ctx_tree'
find_sequence(ct, ctx, reverse = FALSE, ...)
## S3 method for class 'ctx_tree_cpp'
find_sequence(ct, ctx, reverse = FALSE, ...)
ct |
a context tree. |
ctx |
a sequence to search in the context tree |
reverse |
specifies whether the sequence |
... |
additional parameters for the find_sequence function |
The function looks for sequences in general. The is_context()
function can
be used on the resulting object to test if the sequence is in addition a
proper context.
an object of class ctx_node
if the sequence ctx
is represented
in the context tree, NULL
when this is not the case.
sequence are given by default
in the temporal order and not in the "reverse" order used by many VLMC
research papers: older values are on the left. For instance, the context
c(1, 0)
is reported if the sequence 0, then 1 appeared in the time series
used to build the context tree. In the present function, reverse
refers
both to the order used for the ctx
parameter and for the default order used by the resulting ctx_node
object.
dts <- c("A", "B", "C", "A", "A", "B", "B", "C", "C", "A")
dts_tree <- ctx_tree(dts, max_depth = 3)
find_sequence(dts_tree, "A")
## returns NULL as "A" "C" does not appear in dts
find_sequence(dts_tree, c("A", "C"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.