Session Ready
Exercise

Testing whether an object is a time series

When you work to create your own datasets, you can build them as ts objects. Recall the dataset data_vector from the previous exercise, which was just a vector of numbers, and time_series, the ts object you created from data_vector using the ts() function and information regarding the start time and the observation frequency. As a reminder, data_vector and time_series are shown in the plot on the right.

When you use datasets from others, such as those included in an R package, you can check whether they are ts objects using the is.ts() command. The result of the test is either TRUE when the data is of the ts class, or FALSE if it is not.

In this exercise, you'll explore the class of the datasets you've been using throughout this chapter.

Instructions
100 XP
  • Use is.ts() on the data_vector and time_series objects from the previous exercise.
  • Use another call to is.ts() to check the class of the Nile dataset used in earlier exercises.
  • Continue the trend by using is.ts() on the AirPassengers dataset.