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.
This exercise is part of the course
Manipulating Time Series Data in R
Exercise instructions
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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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(
___
)