Bay area R user group, 27 January, 2015

Elegant integration of web presentation technologies and R

Ramnath Vaidyanathan and J.J. Allaire

Use anywhere

  • Integrated RStudio viewer
  • R markdown/knitr documents (like this one)
  • Shiny apps
  • Command-line R (via browser)

Why web?

  • Pervasive
  • Hyperactive herds of developers (some of them first-rate)
  • Portable
  • Mind-blowing awesomeness

Mike Bostock's D3, mrdoob's (Ricardo Cabello) threejs, others…

Examples

threejs 3d scatterplot

library(threejs)

z <- seq(-10, 10, 0.01)
x <- cos(z)
y <- sin(z)
scatterplot3js(x,y,z, color=rainbow(length(z)))

threejs spikey globe

library(maps)
data(world.cities, package="maps")
cities <- world.cities[
            order(world.cities$pop,decreasing=TRUE)[1:1000],]
value  <- 100 * cities$pop / max(cities$pop)

earth <- system.file("images/world.jpg",package="threejs")
globejs(img=earth, lat=cities$lat, long=cities$long, value=value)

threejs global flights data

load("flights.rdata")
globejs(earth, arcs=flights[sample(nrow(flights), 5000), ])

networkD3

library(networkD3)
data(MisLinks, MisNodes)
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 0.7)