library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.2
## Warning: package 'tidyr' was built under R version 4.3.2
## Warning: package 'readr' was built under R version 4.3.2
## Warning: package 'purrr' was built under R version 4.3.2
## Warning: package 'dplyr' was built under R version 4.3.2
## Warning: package 'forcats' was built under R version 4.3.2
## Warning: package 'lubridate' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.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(bea.R)
## Warning: package 'bea.R' was built under R version 4.3.2
## Loading required package: data.table
## Warning: package 'data.table' was built under R version 4.3.2
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
## The following object is masked from 'package:purrr':
##
## transpose
##
## Note: As of February 2018, beaGet() requires 'TableName' for NIPA and NIUnderlyingDetail data instead of 'TableID.' See https://github.us-bea/bea.R for details.
library(ggplot2)
beaKey <- "188FE57B-5C97-47A5-85F6-1D1EF13DBBA5"
beaSpecs <- list(
"UserID" = beaKey,
"Method" = "GetData",
"datasetname" = "NIPA",
"TableName" = "T10705",
"Frequency" = "A",
"Year" = "X")
data <- beaGet(beaSpecs, asWide = FALSE)
## No encoding supplied: defaulting to UTF-8.
# GDP data
data_GDP <- data %>% filter(LineDescription == 'Gross domestic product (GDP)')
head(data_GDP)
## TableName SeriesCode LineNumber LineDescription TimePeriod
## 1: T10705 A191RC 1 Gross domestic product (GDP) 1929
## 2: T10705 A191RC 1 Gross domestic product (GDP) 1930
## 3: T10705 A191RC 1 Gross domestic product (GDP) 1931
## 4: T10705 A191RC 1 Gross domestic product (GDP) 1932
## 5: T10705 A191RC 1 Gross domestic product (GDP) 1933
## 6: T10705 A191RC 1 Gross domestic product (GDP) 1934
## METRIC_NAME CL_UNIT UNIT_MULT DataValue NoteRef
## 1: Current Dollars Level 6 104556 T10705
## 2: Current Dollars Level 6 92160 T10705
## 3: Current Dollars Level 6 77391 T10705
## 4: Current Dollars Level 6 59522 T10705
## 5: Current Dollars Level 6 57154 T10705
## 6: Current Dollars Level 6 66800 T10705
data_GDP$TimePeriod <- as.numeric(data_GDP$TimePeriod)
# plot the graph
ggplot(data = data_GDP) +
(aes(x = TimePeriod, y = DataValue)) +
geom_line(color = "red") +
labs(x = "Year", y = "GDP")
2008 Financial Crisis: The crisis, primarily caused
by the collapse of the housing bubble and subsequent failures in the
banking system, led to a severe contraction in economic activity. It
caused a sharp decline in GDP.
During Covid-19:
Unlike the financial crisis, Covid-19 caused direct and widespread
shutdowns of economic activity. This included closures of businesses,
travel restrictions, and other measures that directly impacted GDP.
What’s more, the pandemic disrupted global supply chains, affecting
production and trade, which are key components of GDP.