Skip to contents

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

Usage

draw(ct, control = draw_control(), ...)

Arguments

ct

a context tree.

control

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

...

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 <- sample(c(0, 1), 100, replace = TRUE)
ctree <- ctx_tree(dts, min_size = 10, max_depth = 2)
draw(ctree)
#> *
#> +-- 0
#> |   +-- 0
#> |   '-- 1
#> '-- 1
#>     +-- 0
#>     '-- 1
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, draw_control(root = "x"))
#> x
#> +-- A
#> |   +-- B
#> |   '-- CD
#> '-- B
#> |   +-- A
#> |   '-- B
#> '-- CD
#>     +-- A
#>     '-- CD