Chord diagram

By Data Tricks, 19 March 2019

A chord diagram is a visual way of displaying inter-relationships between data. Features are arranged in a circle with arcs connecting features which are related.

One of the easiest way to create a chord diagram in R is by using the circlize package.

rm(list=ls())
library(circlize)

#Create data
name=c(3,10,10,3,6,7,8,3,6,1,2,2,6,10,2,3,3,10,4,5,9,10)
feature=paste("feature ", c(1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5) , sep="")
dat <- data.frame(name,feature)
dat <- with(dat, table(name, feature))

#Create the circular plot
chordDiagram(as.data.frame(dat), transparency = 0.5)

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Please note that your first comment on this site will be moderated, after which you will be able to comment freely.

Free data science in R guide

Sign up to our newsletter and we will send you a series of guides containing tips and tricks on data science and machine learning in R.

No thanks

You might also like