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.
Este ejercicio forma parte del curso
Time Series Analysis in R
Instrucciones del ejercicio
- Use the
print()
function to display the River Nile data. The data object is calledNile
- Use the
length()
function to identify the number of elements in yourNile
dataset. - Use
head()
to display the first 10 elements of the Nile dataset. To do so, set then
argument equal to10
. - Use
tail()
to display the last 12 elements of the Nile dataset, again setting an appropriate value to then
argument.
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
# Print the Nile dataset
# List the number of observations in the Nile dataset
# Display the first 10 elements of the Nile dataset
# Display the last 12 elements of the Nile dataset