Skip to contents

This function 'draws' a context tree as a text.

Usage

# S3 method for ctx_tree_cpp
draw(ct, control = draw_control(), frequency = NULL, ...)

# S3 method for ctx_tree
draw(ct, control = draw_control(), frequency = NULL, ...)

Arguments

ct

a context tree.

control

a list of low level control parameters of the text representation. See details and draw_control().

frequency

this parameter controls the display of node level information in the tree. The default NULL value does not include anything. Setting frequency to "total" includes the frequency of the (partial) context of the node, while "detailed" includes the frequency of the states that follow the context (as in contexts.ctx_tree()).

...

additional arguments for draw.

Value

the context tree (invisibly).

Details

The function uses basic "ascii art" to represent the context tree. Characters used to represent the structure of the tree, e.g. branches, can be modified using draw_control().

In addition to the structure of the context tree, draw can represent information attached to the node (contexts and partial contexts). This is controlled by additional parameters depending on the type of the context tree.

Examples

dts_c <- sample(c("A", "B", "CD"), 100, replace = TRUE)
ctree_c <- ctx_tree(dts_c, min_size = 10, max_depth = 2)
draw(ctree_c, frequency = "total")
#> * (100)
#> +-- A (36)
#> |   +-- A (10)
#> |   '-- B (13)
#> |   '-- CD (12)
#> '-- B (33)
#> |   +-- A (15)
#> |   '-- CD (10)
#> '-- CD (30)
#>     +-- A (10)
#>     '-- B (12)
draw(ctree_c, frequency = "detailed")
#> * (36,33,31)
#> +-- A (10,15,11)
#> |   +-- A (2,5,3)
#> |   '-- B (4,7,2)
#> |   '-- CD (4,3,5)
#> '-- B (13,8,12)
#> |   +-- A (5,6,4)
#> |   '-- CD (4,2,4)
#> '-- CD (12,10,8)
#>     +-- A (3,5,2)
#>     '-- B (7,3,2)