Check

Make sure you have a working API key and know how to get data.

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(fredr)

Set your FRED API key

fredr_set_key("2923ccf83015d6b33cfda99a3c83093e")

Get the Unemployment Rate

We will use this example as a template for getting data from FRED.

unratef = fredr_series_observations(
  series_id = "UNRATE",
  observation_start = as.Date("1981-01-01"),
  frequency = "q")

unrate = unratef$value

ung = ggplot(unratef,aes(x=date,y=value)) +
  geom_point(size=.5)
ggplotly(ung)

Structure

Look at structure of unratef.

Solution

str(unratef)
## tibble [183 × 5] (S3: tbl_df/tbl/data.frame)
##  $ date          : Date[1:183], format: "1981-01-01" "1981-04-01" ...
##  $ series_id     : chr [1:183] "UNRATE" "UNRATE" "UNRATE" "UNRATE" ...
##  $ value         : num [1:183] 7.4 7.4 7.4 8.2 8.8 9.4 9.9 10.7 10.4 10.1 ...
##  $ realtime_start: Date[1:183], format: "2026-11-03" "2026-11-03" ...
##  $ realtime_end  : Date[1:183], format: "2026-11-03" "2026-11-03" ...
head(unratef)
## # A tibble: 6 × 5
##   date       series_id value realtime_start realtime_end
##   <date>     <chr>     <dbl> <date>         <date>      
## 1 1981-01-01 UNRATE      7.4 2026-11-03     2026-11-03  
## 2 1981-04-01 UNRATE      7.4 2026-11-03     2026-11-03  
## 3 1981-07-01 UNRATE      7.4 2026-11-03     2026-11-03  
## 4 1981-10-01 UNRATE      8.2 2026-11-03     2026-11-03  
## 5 1982-01-01 UNRATE      8.8 2026-11-03     2026-11-03  
## 6 1982-04-01 UNRATE      9.4 2026-11-03     2026-11-03

Get Explanation for 2008

Submit the following to ChatGPT, Claude, and Gemini.

I have been looking at economic data using FRED. The unemployment rate jumped up in late 2008. Is there a consensus on the cause of this jump? Explain it. I am an undergraduate taking a data analysis class. I have not taken a course in economics.