Question
Exercise 4: time series analysis. Consider the following time series plot of daily morning gold prices, based on the gold data from the forecast package:
Exercise 4: time series analysis.
Consider the following time series plot of daily morning gold prices, based on the gold data from the forecast package:
library(forecast)
autoplot(gold)
We'd like to add a note about the spike due to incorrect value to the plot. First, we wish to find out on which day the spike appears:
spike_date <- which.max(gold)
To add a circle around that point, we add a call to annotate to the plot:
autoplot(gold) +
annotate(geom = "point", x = spike_date, y = gold[spike_date],
size = 5, shape = 21, colour = "red", fill = "transparent")
Using the figure created above and the documentation for annotate, do the following:
- Add the text "Incorrect value" next to the circle.
- Create a second plot where the incorrect value has been removed.
- Read the documentation for the geom geom_hline. Use it to add a red reference line to the plot, at y=400.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started