Description Usage Arguments Details Value See Also Examples
Show tree representation in dot format
1 2 |
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. |
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.
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
).
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.