Faceting with TrelliscopeJS

Visualizing Big Data with Trelliscope in R

Ryan Hafen

Author, TrelliscopeJS

Faceting with TrelliscopeJS

Visualizing Big Data with Trelliscope in R

The Gapminder data

library(gapminder)
head(gapminder)
# A tibble: 6 x 6
  country     continent  year lifeExp      pop gdpPercap
  <fct>       <fct>     <int>   <dbl>    <int>     <dbl>
1 Afghanistan Asia       1952    28.8  8425333       779
2 Afghanistan Asia       1957    30.3  9240934       821
3 Afghanistan Asia       1962    32.0 10267083       853
4 Afghanistan Asia       1967    34.0 11537966       836
5 Afghanistan Asia       1972    36.1 13079460       740
6 Afghanistan Asia       1977    38.4 14880372       786
Visualizing Big Data with Trelliscope in R

Life expectancy over time per country

ggplot(gapminder, aes(year, lifeExp, group = country)) +
  geom_line()

Visualizing Big Data with Trelliscope in R

Faceting on continent

ggplot(gapminder, aes(year, lifeExp, group = country, color = continent)) +
  geom_line() +
  facet_wrap(~ continent, nrow = 1) +
  guides(color = FALSE)

Visualizing Big Data with Trelliscope in R

Faceting on country

ggplot(gapminder, aes(year, lifeExp)) +
  geom_line() +
  facet_wrap(~ country + continent)

Visualizing Big Data with Trelliscope in R

Faceting with TrelliscopeJS

It's as easy as swapping out facet_wrap() for facet_trelliscope().

As with facet_wrap(), control rows and columns with nrow and ncol.

Additional options:

  • Specifying the grid layout with nrow and ncol, similar to facet_wrap().
  • Giving the display a name (name) and description (desc).
  • Specifying where the display should be placed with path.
Visualizing Big Data with Trelliscope in R

Let's practice!

Visualizing Big Data with Trelliscope in R

Preparing Video For Download...