Session Ready
Exercise

Saving time - II

You've saved your flights_xts data to a rds file for future use. But what if you'd like to share your data with colleagues who don't use R?

A second option for saving xts objects is to convert them to shareable formats beyond the R environment, including comma-separated values (CSV) files. To do this, you'll use the write.zoo() command.

Once you've succesfully exported your xts object to a csv file, you can load the data back into R using the read.zoo() command. Unlike readRDS, however, you will need to re-encode your data to an xts object (using as.xts).

Instructions
100 XP
  • Use write.zoo() to save the flights_xts data to "flights_xts.csv". Be sure to specify comma-separated values (",") using the sep argument.
  • Read your file back into R using read.zoo(). Specify the name of the file you exported as well as the method used to separate the data. Take a look at the other arguments but don't change the code. Save this new object as flights2.
  • Encode your flights2 object back into xts using as.xts(). Save your new xts object as flights_xts2.