Selecting a window from a time series
Real-life time series datasets can span decades, as in the case of long-term climate and meteorological studies, financial records, or stock market data. By creating a window from a time series, you can hone in on a specific region of important data or exclude parts of the data that may not be necessary to consider.
In this exercise, you'll select a window from the dow_jones time series, containing real-world stocks information from the Dow Jones Industrial Average – the stock prices from 30 major companies based in the United States.
The dow_jones dataset and the ggplot2, zoo, and lubridate packages are available to you.
Cet exercice fait partie du cours
Manipulating Time Series Data in R
Instructions
Create a window from the
dow_jonesdataset which starts on January 1, 2019, and ends on January 1, 2021; assign this todow_jones_window.Generate an autoplot for the original
dow_jonesdataset with the y-axis label"Price (USD)".Generate an autoplot for the
dow_jones_windowdataset with the y-axis label"Price (USD)".
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Create a window from dow_jones
___ <- ___
# Create an autoplot from the original dow_jones
autoplot(___) +
labs(___)
# Create an autoplot from dow_jones_window
autoplot(___) +
labs(___)