Visualizing with D3 JavaScript Network Graphs from R

diagonalnetwork

Hi all, I want to visualize some of my courses I’ve followed by year. I have found D3 JavaScript Network Graphs from R with some nice and cool visualizations.

In this post I will describe how I transform my data for creating the RadialNetwork and DiagonalNetwork visualizations.

Loading and have a look at the data

First off all I had a Excel file with some of my followed some courses since 2013. I’ve saved it to a csv file courses.csv. Let have a look of the file.

Oke, we have a data.frame of 25 observation of 4 variables (year, month, course and type). Since both visualizations are based on tree diagrams we need to create a tree from my data.frame. After some searching on the internet I’ve found the package data.tree. In this package there is a paragraph called “Create a tree from a data.frame”.

Let’s start to create a tree from my courses

Load the library.

The data.frame is a table and each row is a leaf. We create a path from root to leaf and save that into the data.frame as new column pathString.
Define the hierarchy (Year|Month|Type|Course)

After we have created the pathString we need to convert it to a node, with the package data.tree is that very easy.

The last thing we need is a list-to-list structure before we can plot the two networkD3 visulizatios

Plot the two visulizatios

diagonalnetwork

radialnetwork

Well that look nice!! This package is great!!

This code can also be find on my GitHub

SessionInfo

Related Posts