Code Studio: Time Series
Work with the ts format and Time Series Plots in Base R using AirPassengers, monthly airline passengers from 1949 to 1960.
The program reads a year between 1949 and 1960.
- Plot the whole series with
plot(), with a title. - Take that year's 12 months with
window(AirPassengers, start = c(year, 1), end = c(year, 12)), and draw them over the full series in another colour withlines(). - Print the year's total, and the month (from
month.abb) with the most passengers:
Total: 1520 Busiest month: Jul
Look at the plot: what two patterns do you see across the years, and how does the busiest month change?
Run draws your plot under the output. Check and Submit test the numbers your program prints.
Work with the ts format and Time Series Plots in Base R using AirPassengers, monthly airline passengers from 1949 to 1960.
The program reads a year between 1949 and 1960.
- Plot the whole series with
plot(), with a title. - Take that year's 12 months with
window(AirPassengers, start = c(year, 1), end = c(year, 12)), and draw them over the full series in another colour withlines(). - Print the year's total, and the month (from
month.abb) with the most passengers:
Total: 1520 Busiest month: Jul
Look at the plot: what two patterns do you see across the years, and how does the busiest month change?
Run draws your plot under the output. Check and Submit test the numbers your program prints.