Session Ready
Exercise

Exploring raw time series

The most common first step when conducting time series analysis is to display your time series dataset in a visually intuitive format. The most useful way to view raw time series data in R is to use the print() command, which displays the Start, End, and Frequency of your data along with the observations.

Another useful command for viewing time series data in R is the length() function, which tells you the total number of observations in your data.

Some datasets are very long, and previewing a subset of data is more suitable than displaying the entire series. The head(___, n =___) and tail(___, n =___) functions, in which n is the number of items to display, focus on the first and last few elements of a given dataset respectively.

In this exercise, you'll explore the famous River Nile annual streamflow data, Nile. This time series dataset includes some metadata information. When calling print(Nile), note that Start = 1871 indicates that 1871 is the year of the first annual observation, and End = 1970 indicates 1970 is the year of the last annual observation.

Instructions
100 XP
  • Use the print() function to display the River Nile data. The data object is called Nile
  • Use the length() function to identify the number of elements in your Nile dataset.
  • Use head() to display the first 10 elements of the Nile dataset. To do so, set the n argument equal to 10.
  • Use tail() to display the last 12 elements of the Nile dataset, again setting an appropriate value to the n argument.