Skip to content

Instantly share code, notes, and snippets.

@juba
Forked from timelyportfolio/Readme.md
Last active November 21, 2016 21:00
Show Gist options
  • Save juba/674fdb0c12af961b7b1c85d40925708b to your computer and use it in GitHub Desktop.
Save juba/674fdb0c12af961b7b1c85d40925708b to your computer and use it in GitHub Desktop.
trelliscopejs and scatterD3

trelliscopejs examples with other widgets

Others in the series:

scatterD3

Here is some code for trelliscopejs combined with scatterD3.

library(trelliscopejs)
library(dplyr)
library(tidyr)
library(scatterD3)
library(ggplot2)

xlims <- range(mpg$cty)
ylims <- range(mpg$hwy)
mpg %>%
  group_by(manufacturer, class) %>%
  summarise(
    mean_city_mpg = cog(mean(cty), desc = "Mean city mpg"),
    mean_hwy_mpg = cog(mean(hwy), desc = "Mean highway mpg"),
    panel = panel(
      scatterD3(x=c(cty), y=c(hwy), xlab="City mpg", ylab="Highway mpg",
                xlim=xlims, ylim=ylims)
    )
  ) %>%
  trelliscope(name = "city_vs_highway_mpg", nrow = 2, ncol = 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment