as_treenetdf: Convert one of numerous data types to treeNetwork's 'native'...

Description Usage Arguments Examples

Description

The treeNetwork function uses a 'native' data format that consists of a data frame with minimally 2 vectors/columns, one named 'nodeId' and one named 'parentId'. Other columns in the data frame are also passed on to the JavaScript code and attached to the elements in the D3 visualization so that they can potentially be accessed by other JavaScript functions. This is an advantageous format because:

as_treenetdf can convert from any of the following data types:

Usage

1

Arguments

data

a tree network description in one of numerous forms (see details).

...

other arguments that will be passed on to as_treenetdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
links <- read.csv(header = TRUE, stringsAsFactors = FALSE, text = '
                   source,target,name
                   1,,one
                   2,1,two
                   3,1,three
                   4,1,four
                   5,2,five
                   6,2,six
                   7,2,seven
                   8,6,eight')
                   
 # Convert data
 as_treenetdf(links, cols = c(nodeId = 'source', parentId = 'target'))
 
 # Graph (calls as_treenetdf internally)
 treeNetwork(links, cols = c(nodeId = 'source', parentId = 'target'))

christophergandrud/networkD3 documentation built on May 13, 2019, 7:02 p.m.