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 document 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 | September 21, 2026 |
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 September 21, 2026. |
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 | September 21, 2026 | |
Unemployment Rate | UNRATE | Unemployment Rate | Monthly | % | Seasonally Adjusted | FRED (R) Federal Reserve Bank of St. Louis | September 21, 2026 | |
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 | September 21, 2026 | |
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 | September 21, 2026 |
Login / Create an account at FRED (Federal Reserve Economic Data)
(click person icon at top right)
Follow this link to create a FRED API key which gives you access to download data from your code
Login / Create Posit Cloud account at Posit Cloud
Follow this link to join the
Go into the console in Posit cloud and enter that 32-character FRED API key and in the Posit Cloud console, set the key:
ecodata_set_fredkey("abcd1234efgh5678ijkl9012mnop3456")
(insert your own 32-character key, this one won't work)
This is part of getting_started.R in the project, ECODATA Homework 1
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