Adam Spannbauer

Programmer/Data Scientist/Instructor・Mostly write Python & R・Big fan of OpenCV & p5js


rPackedBar on CRAN

Published Feb 03, 2018

This post is to announce rPackedBar’s release to CRAN and to share a shiny app to visualize twitter interactions using a packed barchart.

This post and the package has been updated due to feedback from Xan Gregg.

About Packed Bars

If you want to read more about the ideas behind packed bars, I’d suggest to read this introduction by the chart’s creator, Xan Gregg. Also in the linked article, he provides an annotated example that serves as a pretty good intro by itself (shown below).

Using Packed Bars in R


#install from CRAN

#install dev version



#use sample data from treemap package
data(GNI2014, package = 'treemap')

#summarize data to plot
my_input_data = GNI2014[, sum(population), by=country]
#make label shorter to fit
my_input_data[country=="United States", country := "USA"]

#packed bar with default settings
p = plotly_packed_bar(my_input_data,
                      label_column = 'country',
                      value_column = 'V1')

plotly::config(p, displayModeBar = FALSE)

rPackedBar Demo App on

If you want to see some more example usage of the rPackedBar package without having to write any code you can check out a toy app I published on The app grabs some tweets for a given user and uses packed bars to plot tweet interactions (as measured by retweets and favorites). You can see example output in the screen shot at the top of this post.

Note: The app uses the functions packedBarOutput & renderPackedBar. At the time of writing this post, these functions are not included in the version of the package on CRAN. They are included in the dev version that can be installed using: devtools::install_github('AdamSpannbauer/rPackedBar')

Update to Post & Package

The updates to the package are only available in the dev version at the time of writing this.