Get startedGet started for free

Identifying the sampling frequency

In addition to viewing your data and plotting over time, there are several additional operations that can be performed on time series datasets.

The start() and end() functions return the time index of the first and last observations, respectively. The time() function calculates a vector of time indices, with one element for each time index on which the series was observed.

The deltat() function returns the fixed time interval between observations and the frequency() function returns the number of observations per unit time. Finally, the cycle() function returns the position in the cycle of each observation.

In this exercise, you'll practice applying these functions to the AirPassengers dataset, which reports the monthly total international airline passengers (in thousands) from 1949 to 1960.

This exercise is part of the course

Time Series Analysis in R

View Course

Exercise instructions

  • Begin by plotting the AirPassengers data using a simple call to plot().
  • Next, list the first and last time observations in AirPassengers using start() and end(), respectively.
  • Finally, gain some additional insight into this dataset by using the time(), deltat(), frequency(), and cycle() commands AirPassengers.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot AirPassengers


# View the start and end dates of AirPassengers



# Use time(), deltat(), frequency(), and cycle() with AirPassengers 



Edit and Run Code