print.tree: Show tree representation in dot format

Description Usage Arguments Details Value See Also Examples

Description

Show tree representation in dot format

Usage

1
2
## S3 method for class 'tree'
print(x, nodef = NULL, edgef = NULL, main = NULL, ...)

Arguments

x

Tree object.

nodef

Function for printing node attributes in dot format.

edgef

Function for printing node attributes in dot format.

main

Title used for printed tree.

...

Ignored.

Details

The ‘nodef’/‘edgef’ functions should print dot format node/edge attributes like ‘[label="node1"]’ to standard output. The ‘nodef’ function is called with two arguments: the current node id and a data frame. The ‘edgef’ function is called with three arguments: the id of the node where the edge starts (the parent node), the id of the node where the edge ends (the child node), and a data frame. In both cases, the data frame is the one that was used to construct the initial tree object (an ancestor of ‘tree’) using make_tree. Rows corresponding to nodes that are not in ‘tree’ were removed from the data frame. By default, nodes are labeled with their id and edges are drawn as arrows from parent to child without any label.

Value

Produces a representation of the tree in dot format. Sometimes that is enough to give you an idea of what the tree looks like. Often, however, it's better to convert that representation into a picture using tools from the open source graph visualization software Graphviz (www.graphviz.org) and look at that instead (see tree2dot).

See Also

make_tree tree2dot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(treeFun)

d <- read.table(textConnection("\
id parents label
0 - a
1 0 b
2 0 c
3 1 d
4 1 e
5 1 f
6 2 g
7 2 h
8 7 i
"), header = TRUE, stringsAsFactors = FALSE)

##         0a
##        / \
##      /     \
##    1b       2c
##   /|\      / \
##  / | \    /   \
## 3d 4e 5f 6g    7h
##                 \
##                  \
##                   8i

print(make_tree(d))

cbaumbach/treeFun documentation built on May 13, 2019, 1:49 p.m.