Get startedGet started for free

Creating a zoo

zoo objects are an essential tool in the time series analyst tool belt; many advanced functions in time series analysis require time series objects. Creating a zoo object from a vector or data frame is the first step in ensuring your data is ready for a time series analysis!

In this exercise, you'll create and visualize a time series of the average price of a particular card from a popular trading card game.

You'll use the core data stored in the vector cards_price, as well as the index vector cards_index, containing the date that each price was sampled.

cards_index, cards_price, and the zoo and ggplot2 packages are available to use.

This exercise is part of the course

Manipulating Time Series Data in R

View Course

Exercise instructions

  • Return the head, or first six observations from cards_index.

  • Return the head, or first six observations from cards_price.

  • Generate a zoo object from your index and core data vectors, and assign it to cards_zoo.

  • Generate an autoplot of cards_zoo.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Return the head of cards_index
___

# Return the head of cards_price
___

# Create a zoo object: cards_zoo
___ <- ___(x = ___, order.by = ___)

# Autoplot cards_zoo
___
Edit and Run Code