ECODATA is an R package for downloading and visualizing economic data
Can pull data from FRED and World Bank
Create reproducible, professional-quality data visualizations, and documenting your data sources
Easy only two or three lines of code
Download data on average 30-year mortgage interest rate from FRED:
ECODATA data frame mydata
:
Get a description of the data
Variable | Code | Description | Frequency | Units | Seasonal Adjustment | Source | URL | Access Date |
---|---|---|---|---|---|---|---|---|
30-Year Fixed Rate Mortgage Average in the United States | MORTGAGE30US | 30-Year Fixed Rate Mortgage Average in the United States | Weekly | % | Not Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | February 03, 2025 |
Cite the data
Variable | Cite |
---|---|
30-Year Fixed Rate Mortgage Average in the United States | FRED (R) Federal Reserve Bank of St. Louis; https://fred.stlouisfed.org/series/MORTGAGE30US; Accessed on February 03, 2025. |
Reproducible: The code is the set of instructions for what you created
Flexible: With more knowledge of R, you can change the data, the graph, the labels, etc.
Efficient: Easy to replicate code for similar variables, similar tasks
Used in other courses: R is used in econometrics (ECO 307), statistics (STAT courses), and others
Coding in R and Python used in industry, even among those who are not computer scientists or data scientists
Even more important / relevant with AI
AI assistance makes coding more accessible
Verification and reproducibility is key with AI-generated content
# Get three variables - Save the list of URLs in an objected called 'variables'
variables <- c("https://fred.stlouisfed.org/series/FEDFUNDS",
"https://fred.stlouisfed.org/series/UNRATE",
"https://fred.stlouisfed.org/series/CPIAUCSL")
# Make up my own names for those variables
varnames <- c("Federal Funds Rate", "Unemployment Rate", "CPI")
# Download all three variables, give them my own names
# Also set frequency = "m" for monthly data
mydata <- get_ecodata(variables, varnames = varnames, frequency = "m")
# Get only Great Recession + Recovery
mydata <- mydata |>
filter(Date >= "2007-01-01" & Date <= "2016-12-31")
ECODATA data frame mydata
:
Inflation is the growth rate of the CPI
ECODATA data frame mydata
:
Variable | Code | Description | Frequency | Units | Seasonal Adjustment | Source | URL | Access Date |
---|---|---|---|---|---|---|---|---|
Federal Funds Rate | FEDFUNDS | Federal Funds Effective Rate | Monthly | % | Not Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | February 03, 2025 | |
Unemployment Rate | UNRATE | Unemployment Rate | Monthly | % | Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | February 03, 2025 | |
CPI | CPIAUCSL | Consumer Price Index for All Urban Consumers: All Items in U.S. City Average | Monthly | Index 1982-1984=100 | Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | February 03, 2025 | |
Inflation | CPIAUCSL | Percent Change in Consumer Price Index for All Urban Consumers: All Items in U.S. City Average | Monthly | Percent | Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | February 03, 2025 |
Login / Create Posit Cloud account at https://posit.cloud
Create your own copy of the ECODATA Exercises project by following:
Click + Save a Permanent Copy
(top-right corner) to save your copy
Login / Create FRED account at https://fred.stlouisfed.org/
(click My Account at top right)
Get your FRED key at https://fredaccount.stlouisfed.org/apikeys
Copy that 32-character key and in the Posit Cloud console, set the key:
ecodata::ecodata_set_fredkey("abcd1234efgh5678ijkl9012mnop3456")
(insert your own 32-character key, this one won’t work)
All the documentation: https://murraylax.org/ecodata/
Walks through many of the most common uses of the package.
Download data for multiple states or countries with ease
Plots with multiple variables, bar plots
Data transformations, computing new quantities