Step 1 reads the data, and Step 2 creates and plots the time series. For more details, refer to the Using time series objects recipe earlier in this chapter.
Step 3 shows the use of the stl function to decompose an additive time series. Since our earlier plot indicated that the amplitude of the fluctuations increased with time, thereby suggesting a multiplicative time series, we applied the log function to convert it into an additive time series and then decomposed it.
Step 4 uses the plot function to plot the results.
Step 5 uses the decompose function to perform a decomposition through moving averages and then plots it.
Step 6 adjusts gas prices for seasonality by subtracting the seasonal component from the original time ...