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.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── 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)
fredr_set_key("2923ccf83015d6b33cfda99a3c83093e")
unratef = fredr_series_observations(
series_id = "UNRATE",
observation_start = as.Date("1980-01-01"),
frequency = "q")
unrate = unratef$value
ung = ggplot(unratef,aes(x=date,y=value)) +
geom_point(size=.5)
ggplotly(ung)
Look at structure of unratef.
str(unratef)
## tibble [183 × 5] (S3: tbl_df/tbl/data.frame)
## $ date : Date[1:183], format: "1980-01-01" "1980-04-01" ...
## $ series_id : chr [1:183] "UNRATE" "UNRATE" "UNRATE" "UNRATE" ...
## $ value : num [1:183] 6.3 7.3 7.7 7.4 7.4 7.4 7.4 8.2 8.8 9.4 ...
## $ realtime_start: Date[1:183], format: "2025-10-28" "2025-10-28" ...
## $ realtime_end : Date[1:183], format: "2025-10-28" "2025-10-28" ...
head(unratef)
## # A tibble: 6 × 5
## date series_id value realtime_start realtime_end
## <date> <chr> <dbl> <date> <date>
## 1 1980-01-01 UNRATE 6.3 2025-10-28 2025-10-28
## 2 1980-04-01 UNRATE 7.3 2025-10-28 2025-10-28
## 3 1980-07-01 UNRATE 7.7 2025-10-28 2025-10-28
## 4 1980-10-01 UNRATE 7.4 2025-10-28 2025-10-28
## 5 1981-01-01 UNRATE 7.4 2025-10-28 2025-10-28
## 6 1981-04-01 UNRATE 7.4 2025-10-28 2025-10-28