0

I'm working on a visualization project in R and thought of creating bar charts for hierarchical data (states with constituencies in it, each constituency possessing a numeric value).

I came across this web page (https://observablehq.com/@d3/hierarchical-bar-chart) which implements exactly this using library "d3" but for JavaScript.

Is there any similar library in R to do this?

Avinash
  • 133
  • 9

2 Answers2

1

I also had similar question before! But I couldn't find any package or code online that does the same thing in R, the closest thing I found was "r2d3" package which allows you to run javascript in R.

So by leveraging the "r2d3" package, I was able to replicate it and put it into a function call "hbar", you can directly source it from my github with the code below: source("https://raw.githubusercontent.com/JohnnyPeng123/hierarchical_bar_chart-/master/hbar.r")

For more details and use case please follow the link below: https://github.com/JohnnyPeng123/hierarchical_bar_chart-

Let me know if you need any help in terms of using this function.

johnnypeng
  • 11
  • 1
0

You can use ggplot.

If you need more help, please share a reproductive example.

Nanov
  • 63
  • 6