Haiding Luo
2023 11 20
install.packages("bea.R", repos = "https://cran.r-project.org")
## 将程序包安装入'C:/Users/pokem/AppData/Local/R/win-library/4.3'
## (因为'lib'没有被指定)
## 程序包'bea.R'打开成功,MD5和检查也通过
##
## 下载的二进制程序包在
## C:\Users\pokem\AppData\Local\Temp\RtmpOmjLep\downloaded_packages里
options(repos = list(CRAN = "https://cran.rstudio.com/"))
library(tidyverse)
## Warning: 程辑包'tidyverse'是用R版本4.3.2 来建造的
## Warning: 程辑包'readr'是用R版本4.3.2 来建造的
## Warning: 程辑包'forcats'是用R版本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.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ 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: 程辑包'bea.R'是用R版本4.3.2 来建造的
## 载入需要的程辑包:data.table
##
## 载入程辑包:'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 <- "9A0899AE-FD05-400B-88FF-44ADB600AF1E"
beaSpecs <- list(
"UserID" = beakey,
"Method" = "GetData",
"datasetname" = "NIPA",
"TableName" = "T10705",
"Frequency" = "A",
"Year" = "X")
bea <- beaGet(beaSpecs, asWide = FALSE)
## No encoding supplied: defaulting to UTF-8.
data <- bea %>%
filter(LineDescription == "Gross domestic product (GDP)")
data$TimePeriod <- as.numeric(data$TimePeriod)
ggplot(data,
aes(x = TimePeriod, y = DataValue)) + geom_line()
During the COVID-19 pandemic in 2019, the spread of the virus led to lockdowns and quarantine measures in many countries and regions, severely limiting economic activities and causing a decline in GDP. Additionally, the spread of the virus led to the closure of many businesses, unemployment, reduced consumer confidence, and decreased investment, all contributing to the economic downturn.
During the 2008 financial crisis, the bursting of the real estate market bubble led to a crisis in the global financial system, which in turn impacted the real economy. Many banks collapsed, businesses went bankrupt, unemployment rates rose, consumer confidence decreased, and investment reduced, all contributing to economic recession and a decline in GDP.