D3.js is a famous JavaScript library that allows one to create extremely flexible SVG graphics however D3 has (at least according to me) a pretty steep learning curve. Further, in order to understand some core concepts, one need to have some basics in HTML, CSS and JavaScript. ddplot aims to simply the process using a set of functions that render several graphics using a simple R API. Finally, ddplot is built upon the amazing r2d3 package which makes it a breeze to interface D3.js with R, so a big thanks to the developers.


Let’s work with the mpg data frame from the ggplot2 package.

library(ggplot2) # needed for the mpg data frame

  data = mpg,
  x = "hwy",
  y = "cty",
  xtitle = "hwy variable",
  ytitle = "cty variable",
  title = "cty and hwy relationship",
  titleFontSize = 20