diagonalNetwork: Create Reingold-Tilford Tree network diagrams.

Description Usage Arguments Source Examples

View source: R/diagonalNetwork.R

Description

Create Reingold-Tilford Tree network diagrams.

Usage

1
2
3
4
diagonalNetwork(List, height = NULL, width = NULL, fontSize = 10,
  fontFamily = "serif", linkColour = "#ccc", nodeColour = "#fff",
  nodeStroke = "steelblue", textColour = "#111", opacity = 0.9,
  margin = NULL)

Arguments

List

a hierarchical list object with a root node and children.

height

height for the network graph's frame area in pixels (if NULL then height is automatically determined based on context)

width

numeric width for the network graph's frame area in pixels (if NULL then width is automatically determined based on context)

fontSize

numeric font size in pixels for the node text labels.

fontFamily

font family for the node text labels.

linkColour

character string specifying the colour you want the link lines to be. Multiple formats supported (e.g. hexadecimal).

nodeColour

character string specifying the colour you want the node circles to be. Multiple formats supported (e.g. hexadecimal).

nodeStroke

character string specifying the colour you want the node perimeter to be. Multiple formats supported (e.g. hexadecimal).

textColour

character string specifying the colour you want the text to be before they are clicked. Multiple formats supported (e.g. hexadecimal).

opacity

numeric value of the proportion opaque you would like the graph elements to be.

margin

an integer or a named list/vector of integers for the plot margins. If using a named list/vector, the positions top, right, bottom, left are valid. If a single integer is provided, then the value will be assigned to the right margin. Set the margin appropriately to accomodate long text labels.

Source

Reingold. E. M., and Tilford, J. S. (1981). Tidier Drawings of Trees. IEEE Transactions on Software Engineering, SE-7(2), 223-228.

Mike Bostock: http://bl.ocks.org/mbostock/4339083.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## Not run: 
#### Create tree from JSON formatted data
## Download JSON data
# Create URL. paste0 used purely to keep within line width.
URL <- paste0("https://cdn.rawgit.com/christophergandrud/networkD3/",
              "master/JSONdata//flare.json")
              
## Convert to list format
Flare <- jsonlite::fromJSON(URL, simplifyDataFrame = FALSE)

## Recreate Bostock example from http://bl.ocks.org/mbostock/4063550
diagonalNetwork(List = Flare, fontSize = 10, opacity = 0.9)

#### Create a tree dendrogram from an R hclust object
hc <- hclust(dist(USArrests), "ave")
diagonalNetwork(as.radialNetwork(hc))
diagonalNetwork(as.radialNetwork(hc), fontFamily = "cursive")

#### Create tree from a hierarchical R list
For an alternative structure see: http://stackoverflow.com/a/30747323/1705044
CanadaPC <- list(name = "Canada", children = list(list(name = "Newfoundland",
                    children = list(list(name = "St. John's"))),
               list(name = "PEI",
                    children = list(list(name = "Charlottetown"))),
               list(name = "Nova Scotia",
                    children = list(list(name = "Halifax"))),
               list(name = "New Brunswick",
                    children = list(list(name = "Fredericton"))),
               list(name = "Quebec",
                    children = list(list(name = "Montreal"),
                                    list(name = "Quebec City"))),
               list(name = "Ontario",
                    children = list(list(name = "Toronto"),
                                    list(name = "Ottawa"))),
               list(name = "Manitoba",
                    children = list(list(name = "Winnipeg"))),
               list(name = "Saskatchewan",
                    children = list(list(name = "Regina"))),
               list(name = "Nunavuet",
                    children = list(list(name = "Iqaluit"))),
               list(name = "NWT",
                    children = list(list(name = "Yellowknife"))),
               list(name = "Alberta",
                    children = list(list(name = "Edmonton"))),
               list(name = "British Columbia",
                    children = list(list(name = "Victoria"),
                                    list(name = "Vancouver"))),
               list(name = "Yukon",
                    children = list(list(name = "Whitehorse")))
))

diagonalNetwork(List = CanadaPC, fontSize = 10)

## End(Not run)

christophergandrud/networkD3 documentation built on Dec. 26, 2017, 6:26 p.m.