Home > Enterprise >  D3 library in R?
D3 library in R?

Time:10-24

I am working with the "r2d3" library in R (enter image description here

Clearly, I am doing something wrong.

Can someone please show me how to fix this?

Thanks!

Note: I tried running the following code in R Console:

r2d3(data = flare, d3_version = 4, script = "bubbles.js")

And this is the error I got:

enter image description here

CodePudding user response:

/../as I understand, this library is intended to perform javascript based data visualizations in R /../

It's more of an interface for existing D3 visualizations.

https://rstudio.github.io/r2d3/index.html provides fairly good overview of the process, you should go through that first. To get that gallery sample working, you first prepare a working directory where you have:

Once you have made sure your working dir is the same where those files are (getwed() / setwd()), running

library(r2d3)
r2d3(data = read.csv("flare.csv"), d3_version = 4, script = "bubbles.js")

in console / script / rmd should render those bubbles. Or you could just clone the repo and have all sample files including Rmd-s - https://github.com/rstudio/r2d3/tree/main/vignettes/gallery/bubbles

RStudio provides some support for D3 scripts, so you can also go through File > New File > D3 Script and paste the bubbles.js content there or open existing bubbles.js file. Assuming you have flare.csv file in working directory, you can click on a Preview to have it rendered in Viewer pane. That's what the

// !preview r2d3 data = read.csv("flare.csv"), d3_version = 4

line in js script header is there for.

  • Related