Plotting and forecasting time series data
Once we have a time series dataset, we want to plot the time series to see the trend. We can also forecast from the given time series.
Getting ready
You have completed the previous recipe and have my_series
time series ready. You also need to install a forecast package.
How to do it...
Perform the following steps in R:
> plot(my_series)
![](https://static.packt-cdn.com/products/9781787284395/graphics/19783034-953c-49ce-90f5-e0889aeffcf6.png)
Plot of m y_series
> plot(AirPassengers)
![](https://static.packt-cdn.com/products/9781787284395/graphics/8c418584-6851-4ea6-90bd-ec6a1fbf619f.png)
Plot of AirPassengers
> cycle(AirPassengers) Output: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1949 1 2 3 4 5 6 7 8 9 10 11 12 1950 1 2 3 4 5 6 7 8 9 10 11 12 1951 1 2 3 4 5 6 7 8 9 10 11 12 1952 1 2 3 4 5 6 7 8 9 10 11 12 1953 1 2 3 4 5 6 7 8 9 10 11 12 1954 1 2 3 4 5 6 7 8 9 10 11 12 1955 1 2 3 4 5 6 7 8 9 10 11 12 1956 1 2 3 4 5 6 7 8 9 10 11 12 1957 1 2 3 4 5 6 7 8...