| title |
descriptionMeta |
descriptionTop |
sectionText |
sectionLink |
DataToVizText |
DataToVizLink |
url |
output |
Advanced chord diagram with R and circlize |
Chord diagram is an efficient way to display flows between entities. This post shows how to build it from an edge list or from an adjacency matrix, using the circlize package. |
[Chord diagram](chord-diagram.html) is an efficient way to display flows between entities. This post shows how to build it from an edge list or from an adjacency matrix, using the `circlize` package. |
Chord section |
chord-diagram.html |
Data to Viz |
data-to-viz.com/graph/chord.html |
123-circular-plot-circlize-package-2 |
| html_document |
| self_contained |
mathjax |
lib_dir |
template |
css |
toc |
toc_float |
toc_depth |
df_print |
false |
default |
libs |
template_rgg.html |
style.css |
true |
true |
2 |
paged |
|
|
```{r global options, include = FALSE}
knitr::opts_chunk$set( warning=FALSE, message=FALSE)
```
# Chord diagram from adjacency matrix
***
The `chordDiagram()` function of the `circlize` package makes it a breeze to build chord diagrams from adjacency matrix in R.
The adjacency matrix displays all origins in rows, and all destinations in columns. Each cell is filled with a numeric value specifying the flow strength.
Note: visit the [chord section](chord-diagram.html) of the gallery or the circlize [vignette](https://cran.r-project.org/web/packages/circlize/vignettes/circlize.pdf) for more chord examples.
```{r thecode, echo=FALSE, out.width = "100%", fig.height=7}
# Create an adjacency matrix:
# a list of connections between 20 origin nodes, and 5 destination nodes:
numbers
```{r thecode, eval=FALSE}
```
# Chord diagram from edge list
***
Another common format to store flow information iis the edge list. Basically, all connections are stored one by one in a 2 columns file, listing the origin and destination of each.
Since the `chordDiagram()` function expects an adjacency matrix as input, it is required to use the `table()` function for reformating, as described below:
```{r thecode2, echo=FALSE, out.width = "100%", fig.height=7}
# Create an edge list: a list of connections between 10 origin nodes, and 10 destination nodes:
origin
```{r thecode2, eval=FALSE}
```
```{r, echo=FALSE}
htmltools::includeHTML("htmlChunkRelatedFlow.html")
```