НачатьНачать бесплатно

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.

Это упражнение является частью курса

Manipulating Time Series Data in R

Посмотреть курс

Инструкции к упражнению

  • 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".

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Create a year-monthly index
___

# Create a zoo object from the year-month index and monthly data
___

# Autoplot with titles and axis labels
___
Редактировать и запускать код