Exercise

More than a matrix

It is best to think of xts objects as normal R matrices, but with special powers. These powers let you manipulate your data as a function of time, as your data is now self-aware of when it exists in time. Before we can start to exploit these powers, it will be helpful to see how xts objects relate to their base-R relatives.

In this exercise, you will get a feel for xts and how it behaves like a matrix object. The xts object ex_matrix and matrix object core have been pre-loaded for you.

Instructions

100 XP
  • Load the xts package using the library() function.
  • Look at the structure of the sample xts called ex_matrix using str().
  • Given that ex_matrix is a matrix, extract the 3rd row and 2nd column.
  • Now take the matrix core and extract the 3rd row and 2nd column. Notice the difference.