1. Learn
  2. /
  3. Courses
  4. /
  5. Manipulating Time Series Data in R

Exercise

zoo::yearmon

When processing time series data that's based on the month and quarter of a year, it's often necessary to use the yearmon and yearqtr classes from the zoo package. By doing so, you can have data where the specific date of an observation is unknown or is unnecessary.

In this exercise, you'll work with a vector of sales data, monthly_data, and an index of dates of observations, date_index_month, with each observation occurring on the first of the month.

The above datasets, as well as the ggplot2, zoo, and lubridate packages are available to you.

Instructions

100 XP
  • Convert date_index_month to the yearmon class and assign it to index_yearmon.

  • Using the values in monthly_data and the index_yearmon index, create a zoo object, monthly_sales.

  • Autoplot monthly_sales with the x-axis label "Month", y-axis label "Sales ($100k)", and title "Corporate Sales Data".