extract_tree: Downstream extraction of subtrees

Description Usage Arguments Value Examples

Description

Downstream extraction of subtrees

Usage

1
extract_tree(tree, depth, from = tree$root)

Arguments

tree

Tree object from which to extract subtree.

depth

Number of levels to extract from ‘tree’.

from

Id of node where extraction should begin.

Value

Returns a subtree of ‘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
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)
print(extract_tree(tr, 2))
print(extract_tree(tr, 2, from = "1"))

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