Learn R Programming

networkD3 (version 0.4)

chordNetwork: Create Reingold-Tilford Tree network diagrams.

Description

Create Reingold-Tilford Tree network diagrams.

Usage

chordNetwork(Data, height = 500, width = 500, initialOpacity = 0.8,
  useTicks = 0, colourScale = c("#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78",
  "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b",
  "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d",
  "#17becf", "#9edae5"), padding = 0.1, fontSize = 14,
  fontFamily = "sans-serif", labels = c(), labelDistance = 30)

Arguments

Data

A square matrix or data frame whose (n, m) entry represents the strength of the link from group n to group m

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)

initialOpacity

specify the opacity before the user mouses over the link

useTicks

integer number of ticks on the radial axis. The default is `0` which means no ticks will be drawn.

colourScale

specify the hexadecimal colours in which to display the different categories. If there are fewer colours than categories, the last colour is repeated as necessary (if NULL then defaults to D3 colour scale)

padding

specify the amount of space between adjacent categories on the outside of the graph

fontSize

numeric font size in pixels for the node text labels.

fontFamily

font family for the node text labels.

labels

vector containing labels of the categories

labelDistance

integer distance in pixels (px) between text labels and outer radius. The default is `30`.

Examples

Run this code
# NOT RUN {
#### Data about hair colour preferences, from 
## https://github.com/mbostock/d3/wiki/Chord-Layout

hairColourData <- matrix(c(11975,  1951,  8010, 1013,
                            5871, 10048, 16145,  990,
                            8916,  2060,  8090,  940,
                            2868,  6171,  8045, 6907),
                            nrow = 4)
                            
chordNetwork(Data = hairColourData, 
             width = 500, 
             height = 500,
             colourScale = c("#000000", 
                             "#FFDD89", 
                             "#957244", 
                             "#F26223"),
             labels = c("red", "brown", "blond", "gray"))

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab