ПочатиПочніть безкоштовно

zoo::yearqtr

Seen most often in financial and business settings, the concept of 'quarters of a year' is important in time series analysis. The zoo package introduces the yearqtr class, which stores both the year and quarter components of a date.

In this exercise, you'll work with quarterly sales data, quarterly_data, and an index of dates of observations, date_index_quarter, with each observation occurring each quarter of the year (every three months).

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

Ця вправа є частиною курсу

Manipulating Time Series Data in R

Переглянути курс

Інструкції до вправи

  • Create an index, index_yearqtr, by converting the date_index_quarter vector to the yearqtr class.

  • Create quarterly_sales, a zoo based on the data in quarterly_data and the index you created, index_yearqtr.

  • Add the x-axis label "Quarter", the y-axis label "Quarterly Sum ($100k)", and the title "Quarterly Sales Report".

Інтерактивна практична вправа

Спробуйте виконати цю вправу, доповнивши цей зразок коду.

# Create a year-quarter index
___

# Create the quarterly_sales zoo object
___

# Autoplot with axis labels and a title
___
Редагувати та запускати код