rd3.jsr2d3

R2D3 as compared to D3.js


I want to use the R2D3 pacakge in R but am unsure of this package's relationship to the D3.js library. Does R2D3 limit the functionality of D3 in any way? Can we use all of the D3 functions and features in R with R2D3?


Solution

  • At its simplest: R2D3 is essentially an R package that allows binding data to a JavaScript D3 visualization: R does your data manipulation, D3 (and JavaScript) handles your visualization.

    To focus on your question:

    You can use all the standard methods of D3 (v3, 4, or 5) of D3 in your visualization script - there is no modification or limiting of the D3 library within R2D3. As you are working with regular D3, JavaScript, and HTML, the visualization script must still be valid JavaScript. Consequently, to create visualizations with R2D3 effectively, you must be familiar with D3 and JavaScript.

    To further clarify your question: "Can we use all of the D3 functions and features in R with R2D3": you can assign data to a javascript/D3 visualization, but you aren't accessing D3 functions or methods directly in R. You are only binding data to an external D3 script with R.


    There are possible limitations, not on D3, but on the visualization:

    Depending on your end set up, there can be some limitations in back and forth communication between the visualization and R and interaction between web components created with different libraries. These are limitations of things other than D3, but are things which might affect a D3 visualization, these limitations can be overcome with some work.

    R2D3 also limits javascript console logging for troubleshooting, but this can also be overcome (see here). For visualizations with static data, there are essentially no limitations.