Manipulating Time Series Data with xts and zoo in R

The xts and zoo packages make the task of managing and manipulating ordered observations fast and mistake free.

Start Course for Free
4 Hours15 Videos55 Exercises38,674 Learners
4500 XP

Create Your Free Account

GoogleLinkedInFacebook

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies


Course Description

Time series are all around us, from server logs to high frequency financial data. Managing and manipulating ordered observations is central to all time series analysis. The xts and zoo packages provide a set of powerful tools to make this task fast and mistake free. In this course, you will learn everything from the basics of xts to advanced tips and tricks for working with time series data in R.

  1. 1

    Introduction to eXtensible Time Series, using xts and zoo for time series

    Free

    xts and zoo are just two of the many different types of objects that exist in R. This chapter will introduce the basic objects in xts and zoo and their components, and offers examples of how to construct and examine the data.

    Play Chapter Now
    Introducing xts and zoo objects
    50 xp
    What is an xts object?
    50 xp
    More than a matrix
    100 xp
    Your first xts object
    100 xp
    Deconstructing xts
    100 xp
    Time based indices
    100 xp
    Importing, exporting and converting time series
    50 xp
    Converting xts objects
    100 xp
    Importing data
    100 xp
    Exporting xts objects
    100 xp
  2. 2

    First Order of Business - Basic Manipulations

    Now that you can create basic xts objects, it's time to see how powerful they can be. This chapter will cover the basics of one of the most useful features of xts: time based subsetting. From there you'll explore additional ways to extract data using time phrases, and conclude with how to do basic operations like adding and subtracting your xts objects.

    Play Chapter Now
  3. 3

    Merging and modifying time series

    One of the most important parts of working with time series data involves creating derived time series. To do this effectively, it is critical to keep track of dates and times. In this chapter you will look at how xts handles merging new columns and rows into existing data, how to deal with the inevitable missing observations in time series, and how to shift your series in time.

    Play Chapter Now
  4. 4

    Apply and aggregate by time

    Now the fun begins! A very common usage pattern for time series is to calculate values for disjoint periods of time or aggregate values from a higher frequency to a lower frequency. For most series, you'll often want to see the weekly mean of a price or measurement. You may even find yourself looking at data that has different frequencies and you need to normalize to the lowest frequency. This chapter is where it all happens. Hang tight, and lets get going!

    Play Chapter Now
  5. 5

    Extra features of xts

    Now that you are comfortable with most of the core features, its time to explore some of the lesser known (but powerful!) aspects of working with xts. In this final chapter you will use the internals of the index to find repeating itervals, see how xts provides intuitive time zone support, and experiment with ways to explore your data by time - including identifying frequency and coverage in time. Let's finish this course!

    Play Chapter Now

In the following tracks

Finance FundamentalsQuantitative AnalystTime Series

Collaborators

Lore Dirick
DataCamp Content Creator Headshot

DataCamp Content Creator

Course Instructor

DataCamp offers interactive R, Python, Spreadsheets, SQL and shell courses. All on topics in data science, statistics, and machine learning. Learn from a team of expert teachers in the comfort of your browser with video lessons and fun coding challenges and projects.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA