Time series analysis
Question
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.
Get your college paper done by experts
Do my question How much will it cost?Place an order in 3 easy steps. Takes less than 5 mins.
Leave a Reply
Want to join the discussion?Feel free to contribute!