induced_tree: Build tree induced by set of node ids.

Description Usage Arguments Value See Also Examples

Description

Build tree induced by set of node ids.

Usage

1
induced_tree(ids, tree)

Arguments

ids

Character vector of node ids.

tree

Tree object.

Value

Returns the subtree of ‘tree’ that is induced by ‘ids’, that is, the tree consisting of the nodes of ‘tree’ with ids in ‘ids’ and all their ancestor nodes.

See Also

make_tree

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
28
29
30
31
32
33
34
35
36
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

tr <- make_tree(d)

itr1 <- induced_tree(c("1","8"), tr)
itr2 <- induced_tree(c("2","5"), tr)

## Not run: 
tree2dot(itr1, "subtree1.dot")
tree2dot(itr2, "subtree2.dot")

## End(Not run)

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