d3r is on CRAN, so install with
install.packages("d3r") or for the
absolute latest use
d3.js dependency injection in R easy with
d3_dep_v6(), and the newest
d3_dep_v7(). These functions work well with
library(htmltools) library(d3r) # check web developer tools to see d3 is available browsable( attachDependencies( tagList(), d3_dep_v7() ) ) # or include directly in a taglist; I prefer this method. browsable( tagList( h1("I have d3 version ", span(id="version")), tags$script("d3.select('#version').text(d3.version)"), d3_dep_v7() ) )
Also, I will commit to keeping
d3r up-to-date with
d3.js, so you’ll
no longer need multiple copies of
d3.js for your
htmlwidgets. If you
htmlwidget author, you will no longer need to worry every time
d3.js gets a new release. See
for an example of using
d3r with your
d3.js hierarchies can be very difficult.
data.frame to a nested
ready for work with
As another example, let’s go from
library(treemap) library(d3r) d3_nest( treemap::random.hierarchical.data(), value_cols = "x" )
rpart and similar objects in
R are very difficult to convert but
make perfect subjects for
d3 hierarchical layouts.
convert these objects for easy usage with
#devtools::install_github("timelyportfolio/d3treeR") library(d3treeR) library(d3r) # example from ?rpart data("kyphosis", package="rpart") rp <- rpart::rpart( Kyphosis ~ Age + Number + Start, data = kyphosis ) # get the json hierarchy d3_party(tree=rp) # interactive plot with d3treeR d3tree2( d3_party(tree=rp), celltext="description", valueField="n" )
d3.js network of
links is a very common
d3r::d3_igraph will do this for you.
library(igraph) library(d3r) d3_igraph(igraph::watts.strogatz.game(1, 50, 4, 0.05))
I have a whole lot of ideas. Please let me know yours, and let’s make this package great.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.