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

Connected

Exercise

Finding overlapping indices

Time series are said to overlap when there are observations in both time series with the same index, meaning they occur at the same point in time.

By creating a subset using the %in% operator, the overlapping points can be filtered out of one of the time series, allowing the two datasets to be combined.

In this exercise, you'll take two time series, coffee and coffee_overlap, and remove the elements that overlap.

The datasets coffee and coffee_overlap, as well as the zoo and lubridate packages, are available to you already.

Instructions

100 XP
  • Use the value matching operator %in% to determine the indices of coffee_overlap that overlap with the indices of coffee.

  • Use square brackets ([, ]) and the negation operator (!) to extract the values of coffee_overlap which are not part of overlapping_index.

  • Combine the coffee time series with coffee_subset and view the resulting autoplot.