Aan de slagGa gratis aan de slag

Customizing the gapminder display

Let's put some of these features to the test with our by-country life expectancy trajectory plot. Note that we are again working with just the two countries from Oceania.

Deze oefening maakt deel uit van de cursus

Visualizing Big Data with Trelliscope in R

Cursus bekijken

Oefeninstructies

  • Add a geom_smooth() layer to add a fitted linear model using the "lm" method.
  • Set the scales to be "sliced".
  • With the linear model layer added to the plot, specify that automatic cognostics should be computed for this display and explore what new cognostics this layer adds to the display.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

library(trelliscopejs)
library(ggplot2)

# Create the plot
ggplot(gapminder, aes(year, lifeExp)) +
  geom_point() +
  geom_smooth(method = ___, se = FALSE) +
  facet_trelliscope(~ country + continent,
    name = "lifeExp_by_country",
    desc = "Life expectancy vs. year for 142 countries.",
    nrow = 1, ncol = 2,
    # Set the scales
    scales = ___,
    # Specify automatic cognistics
    auto_cog = ___)
Code bewerken en uitvoeren