Exercise

Saving time - I

You've now successfully converted your flights data into an xts object, plotted information over time, and calculated a few valuable metrics to help you proceed with analysis. You've even been able to conduct some quick descriptive analysis on your data by plotting these metrics over time.

The final step in any time series data manipulation is to save your xts object so you can easily return to it in the future.

As a first step, you'll want to save your xts object as a rds file for your own use. To do this, you'll use the command saveRDS(), which saves your object to a file with the name you specify (using the file argument). By default, saveRDS() will save to the current working directory.

When you're ready to return your saved data, you can use the readRDS() command to reopen the file. As you'll see in this exercise, this method maintains the class of your xts object.

Instructions

100 XP
  • Use saveRDS() to save your flights_xts data object to a rds file. Call this file "flights_xts.rds".
  • Open your rds file using readRDS(). Save your new data as flights_xts2.
  • Use class() to check the class of your new flights_xts2 object.