In the first part of A pick of the best R packages for interactive plots and visualizations, we saw the best packages to do interactive plot in R. Now, let’s see what are the best packages for interactive and complex visualizations.
While plots tend are representing ‘classic’ data. These plots have an x-axis a y-axis and one or two other variables represented as colors, size or symbols. Visualizations are to represent data that are not structured in a ‘regular’ way, for instance:
- Network and graph data (for instance social network connections)
- Sequential data (for example a consumer journey on a website or in a shop)
- Hierarchical data (to represent group imbricated like a Russian Doll)
- Textual data
Interactive plots 1: Network and graph data
NetworkD3 is a wrapper for d3 network plots, it will hell you draw simple and force-directed network, Sankey diagrams and dendrogram network. The overall syntax is easy, you need to provide the list of nodes and the list of links. For instance, this code snippet (from the package Github) will draw a force-directed plot:
# Load data data(MisLinks) data(MisNodes) # Plot forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8)
- Trigger an action when selecting a node
- graph edit with an interactive menu
- interface with igraph
- Highlight by groups, nodes id, closest neighbors, …
Interactive plots 2: Sequential data
By sequential data, we mean a sequence of different actions, page visited or a conversion funnel for instance.
SunburstR from timely portfolio is a wrapper for sequential sunburst in D3.js, you can see an example here. Sunbursts are an awesome way to visualize sequences and will make the easier to understand for your audience.
Thanks to the package, you will need to change your path to a sequence of shape ‘Step A – Step B – Step C’ and to count the number of visits on this given sequence, then the wrapper will do the work for you!
D3partitionR also offers a way to plot a Sunburst with D3.js, this time the sunburst is zoomable. Hence, the package is useful for long sequences since zooming will allow you to place the root of the sunburst further in the sequence.
Interactive plots 3: Hierarchical data
Hierarchical data are data structured like nested lists (basically trees).
d3Tree use D3.js and its tree structure to plot interactive tree. The main advantage of the package is the possibility to use the tree as an interactive filter for your data. The data conversion is easy with a dedicated function which also lets you choose a tooltip column.
d3treeR, by timely portfolio, is a wrapper for D3.js treemap. Again the syntax is convenient to use.
d3partitionR is specialized in plotting hierarchical data using treemaps, circle treemaps, and collapsible trees. This is basically a D3.js wrapper for R and has several options:
- Legend and tooltip customisations
- Possibilities to use the interactive plot as a Shiny input and hence do filtering
Interactive plots 4: Textual data
Textual data are often used to do text analysis or sentiment analysis.
This library helps you to create interactive word clouds. The library is really great and will help you to create complex word cloud:
- Specific shape using a .png (you can replicate the Twitter bird)
- Shape using a word, your word cloud will follow the shape of a given word
- Color selection background selection, ….
ggplot2 + plotly
Ggplot and plotly can also be used to plot word projection in a vector space after using PCA or T-sne. This was the technique used in the semantic analysis of Twitter.
If you like this post, you can follow our newsletter: