Aan de slagGa gratis aan de slag

zoo and ggplot2

zoo objects, much like data frames, can be visualized with functions from the ggplot2 package. While this course doesn't go into too much detail regarding ggplot2 plots and functions, it's nonetheless helpful to review the syntax for more advanced plotting techniques than using autoplot() alone.

In this exercise, you'll explore using zoo and ggplot2 together. You'll take the card_prices time series from the previous exercise and generate a ggplot, complete with proper labels, a title, and a theme!

zoo, ggplot2, and card_prices are available to use.

Deze oefening maakt deel uit van de cursus

Manipulating Time Series Data in R

Cursus bekijken

Oefeninstructies

  • Within the call to aes(), enter the appropriate mappings to the x and y axes.

  • Plot the time series as a line, with the color in red.

  • Use the light theme from ggplot2

  • Include the axis labels and title: "Index" for the x-axis, "Price (EUR)" for the y-axis, and "Daily Card Prices for Trading Card Game" for the title.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Enter the x and y axis mapping aesthetics
ggplot(card_prices, aes(x = ___, y = ___)) + 
  scale_y_continuous() + 
  # Plot the data with a red-colored line
  ___ + 

  # Use the light theme
  ___ + 

  # Enter the appropriate axis labels and title
  labs(
    ___
  )
Code bewerken en uitvoeren