Is there a ggplot2 extension package that can produce a table/horizontal bar chart viz similar to one on Fivethirty Eight. Ideally I would like the ability to add a second or even third bar chart and additional text columns.
I've been Googlging and looking at ggplot chart galleries, but haven't come across anything yet.

A workaround would be to use the DT package. This renders an HTML table, but depending on your needs you could use this one. In RStudio you can also easily export the table to any picture format:
library(DT)
dat <- data.frame(CANDIDATE = c("Biden", "Sanders", "Gabbard", "O'Rourke",
"Warren", "Yang", "Buttigieg", "Castro",
"Harris", "Klobuchar", "Booker", "Steyer"),
EXCLUSIVE = c(218, 100, 11, 29, 107, 14, 27, 6, 23, 8, 4, 1),
TOTAL = c(996, 683, 83, 245, 917, 187, 437, 105, 433, 180, 201, 84),
SHARE = c(21.9, 14.6, 13.1, 11.7, 11.6, 7.4, 6.2,
5.7, 5.2, 4.2, 2.2, 1.4) / 100)
datatable(dat, options = list(
columnDefs = list(list(className = "dt-left", targets = 4)))) %>%
formatPercentage("SHARE", 1) %>%
formatStyle("SHARE",
background = styleColorBar(dat$SHARE, "steelblue", -90), backgroundPosition = "left")

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With