Back to Browse

Creating Annual Averages from Monthly Data Using an R Loop

5.1K views
Dec 16, 2020
6:00

Here, we subset each 12 months within a year to calculate annual averages of a monthly time series for real oil prices. A key goal is to write a for() loop that captures the logic of correct start and end dates for each 12-month subset. Further code is written to append a column of years and to plot the new time series. This method can be modified for quarterly data or other applications. The associated .R file can be found at can be found at https://github.com/hegerty/ECON343/.

Download

0 formats

No download links available.

Creating Annual Averages from Monthly Data Using an R Loop | NatokHD