Question 2

Initial Setup

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0     ✔ purrr   1.0.1
## ✔ tibble  3.1.8     ✔ dplyr   1.1.0
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.4     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(bea.R)
## Loading required package: data.table
## 
## Attaching package: 'data.table'
## 
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## 
## The following object is masked from 'package:purrr':
## 
##     transpose
## 
## Creating a generic function for 'toJSON' from package 'jsonlite' in package 'googleVis'
## 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.
beaKey <- "080D210A-54D6-4EF8-ABE5-DC1995EAF7EC"

Using BEA APIs

beaSets(beaKey = beaKey)
## No encoding supplied: defaulting to UTF-8.
## $Dataset
##                DatasetName                   DatasetDescription
## 1                     NIPA                 Standard NIPA tables
## 2       NIUnderlyingDetail Standard NI underlying detail tables
## 3                      MNE            Multinational Enterprises
## 4              FixedAssets         Standard Fixed Assets tables
## 5                      ITA  International Transactions Accounts
## 6                      IIP    International Investment Position
## 7              InputOutput                    Input-Output Data
## 8            IntlServTrade         International Services Trade
## 9            GDPbyIndustry                      GDP by Industry
## 10                Regional                   Regional data sets
## 11 UnderlyingGDPbyIndustry           Underlying GDP by Industry
## 12      APIDatasetMetaData    Metadata about other API datasets
## 
## attr(,"params")
##   ParameterName                       ParameterValue
## 1        USERID 080D210A-54D6-4EF8-ABE5-DC1995EAF7EC
## 2        METHOD                       GETDATASETLIST
## 3  RESULTFORMAT                                 JSON
beaSearch("GDP", beaKey = beaKey)
## Creating first-time local copy of metadata for all datasets - only done once.
## Datasets will be updated only if timestamps indicate metadata obsolete in future searches,
## and only obsolete metadata sets will be updated (it's faster this way).
## 
## No encoding supplied: defaulting to UTF-8.
## Warning in beaSearch("GDP", beaKey = beaKey): Regional metadata is missing from
## /Library/Frameworks/R.framework/Versions/4.2/Resources/library/beaR/data and
## may be locked for updating on the BEA API; searching national metadata only.
##     SeriesCode RowNumber                                LineDescription
##  1:     A191RO        10                   Gross domestic product (GDP)
##  2:   PE000009       330                         Average of GDP and GDI
##  3:     A191RL        10                   Gross domestic product (GDP)
##  4:   PB000009       130                         Average of GDP and GDI
##  5:   PA000009       200        Average of GDP and GDI, current dollars
##  6:     A191RC        10                   Gross domestic product (GDP)
##  7:   LA000009       290                         Average of GDP and GDI
##  8:   SB000008       360 Statistical discrepancy as a percentage of GDP
##  9:     A191RX        10                   Gross domestic product (GDP)
## 10:   LB000009       130                         Average of GDP and GDI
## 11:     A191RL        20                   Gross domestic product (GDP)
## 12:   PB000009        40                         Average of GDP and GDI
## 13:     A191RC        20                   Gross domestic product (GDP)
## 14:   LA000009        40                         Average of GDP and GDI
## 15:     A191RX        20                   Gross domestic product (GDP)
## 16:   LB000009        40                         Average of GDP and GDI
## 17:     A191RX        10                   Gross domestic product (GDP)
## 18:     BB00RL       120     GDP less final sales of domestic computers
## 19:     BB00RX        20     GDP less final sales of domestic computers
## 20:     A191RX        20                   Gross domestic product (GDP)
## 21:     SWGXSL       120               GDP less final sales of software
## 22:     SWGXSX        30               GDP less final sales of software
## 23:     A191RL       110                                            GDP
## 24:     A191RO        10                   Gross domestic product (GDP)
## 25:   PE000009       330                         Average of GDP and GDI
## 26:     A191RL        10                   Gross domestic product (GDP)
## 27:   PB000009       130                         Average of GDP and GDI
## 28:   PA000009       200        Average of GDP and GDI, current dollars
## 29:     A191RC        10                   Gross domestic product (GDP)
## 30:   LA000009       290                         Average of GDP and GDI
## 31:   SB000008       360 Statistical discrepancy as a percentage of GDP
## 32:     A191RX        10                   Gross domestic product (GDP)
## 33:   LB000009       130                         Average of GDP and GDI
## 34:     A191RL        20                   Gross domestic product (GDP)
## 35:   PB000009        40                         Average of GDP and GDI
## 36:     A191RC        20                   Gross domestic product (GDP)
## 37:   LA000009        40                         Average of GDP and GDI
## 38:     A191RX        20                   Gross domestic product (GDP)
## 39:   LB000009        40                         Average of GDP and GDI
## 40:     A191RX        10                   Gross domestic product (GDP)
## 41:     BB00RL       120     GDP less final sales of domestic computers
## 42:     BB00RX        20     GDP less final sales of domestic computers
## 43:     A191RX        20                   Gross domestic product (GDP)
## 44:     SWGXSL       120               GDP less final sales of software
## 45:     SWGXSX        30               GDP less final sales of software
## 46:     A191RL       110                                            GDP
##     SeriesCode RowNumber                                LineDescription
##     LineNumber ParentLineNumber Tier Path TableID        DatasetName
##  1:          1                     0    1  T10111               NIPA
##  2:         32                     0   32  T10111               NIPA
##  3:          1                     0    1  T10701               NIPA
##  4:         12                     0   12  T10701               NIPA
##  5:         19                     0   19  T10701               NIPA
##  6:          1                     0    1  T10705               NIPA
##  7:         27                     0   27  T10705               NIPA
##  8:         34                     0   34  T10705               NIPA
##  9:          1                     0    1  T10706               NIPA
## 10:         12                     0   12  T10706               NIPA
## 11:          1                     0    1  T11701               NIPA
## 12:          3                     0    3  T11701               NIPA
## 13:          1                     0    1  T11705               NIPA
## 14:          3                     0    3  T11705               NIPA
## 15:          1                     0    1  T11706               NIPA
## 16:          3                     0    3  T11706               NIPA
## 17:          1                     0    1  U90200               NIPA
## 18:         11                     0   11  U90200               NIPA
## 19:          2                     0    2  U90200               NIPA
## 20:          1                     0    1  U90300               NIPA
## 21:         10                     0   10  U90300               NIPA
## 22:          2                     0    2  U90300               NIPA
## 23:          9                     0    9  U90300               NIPA
## 24:          1                     0    1  T10111 NIUnderlyingDetail
## 25:         32                     0   32  T10111 NIUnderlyingDetail
## 26:          1                     0    1  T10701 NIUnderlyingDetail
## 27:         12                     0   12  T10701 NIUnderlyingDetail
## 28:         19                     0   19  T10701 NIUnderlyingDetail
## 29:          1                     0    1  T10705 NIUnderlyingDetail
## 30:         27                     0   27  T10705 NIUnderlyingDetail
## 31:         34                     0   34  T10705 NIUnderlyingDetail
## 32:          1                     0    1  T10706 NIUnderlyingDetail
## 33:         12                     0   12  T10706 NIUnderlyingDetail
## 34:          1                     0    1  T11701 NIUnderlyingDetail
## 35:          3                     0    3  T11701 NIUnderlyingDetail
## 36:          1                     0    1  T11705 NIUnderlyingDetail
## 37:          3                     0    3  T11705 NIUnderlyingDetail
## 38:          1                     0    1  T11706 NIUnderlyingDetail
## 39:          3                     0    3  T11706 NIUnderlyingDetail
## 40:          1                     0    1  U90200 NIUnderlyingDetail
## 41:         11                     0   11  U90200 NIUnderlyingDetail
## 42:          2                     0    2  U90200 NIUnderlyingDetail
## 43:          1                     0    1  U90300 NIUnderlyingDetail
## 44:         10                     0   10  U90300 NIUnderlyingDetail
## 45:          2                     0    2  U90300 NIUnderlyingDetail
## 46:          9                     0    9  U90300 NIUnderlyingDetail
##     LineNumber ParentLineNumber Tier Path TableID        DatasetName
##                                                                                                                                          TableName
##  1:                                                            Table 1.1.11. Real Gross Domestic Product: Percent Change From Quarter One Year Ago
##  2:                                                            Table 1.1.11. Real Gross Domestic Product: Percent Change From Quarter One Year Ago
##  3:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
##  4:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
##  5:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
##  6:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
##  7:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
##  8:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
##  9:              Table 1.7.6. Relation of Real Gross Domestic Product, Real Gross National Product, and Real Net National Product, Chained Dollars
## 10:              Table 1.7.6. Relation of Real Gross Domestic Product, Real Gross National Product, and Real Net National Product, Chained Dollars
## 11: Table 1.17.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates
## 12: Table 1.17.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates
## 13:                                                   Table 1.17.5. Gross Domestic Product, Gross Domestic Income, and Other Major NIPA Aggregates
## 14:                                                   Table 1.17.5. Gross Domestic Product, Gross Domestic Income, and Other Major NIPA Aggregates
## 15:                        Table 1.17.6. Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates, Chained Dollars
## 16:                        Table 1.17.6. Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates, Chained Dollars
## 17:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 18:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 19:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 20:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 21:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 22:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 23:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 24:                                                            Table 1.1.11. Real Gross Domestic Product: Percent Change From Quarter One Year Ago
## 25:                                                            Table 1.1.11. Real Gross Domestic Product: Percent Change From Quarter One Year Ago
## 26:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
## 27:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
## 28:   Table 1.7.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross National Product, and Real Net National Product
## 29:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
## 30:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
## 31:            Table 1.7.5. Relation of Gross Domestic Product, Gross National Product, Net National Product, National Income, and Personal Income
## 32:              Table 1.7.6. Relation of Real Gross Domestic Product, Real Gross National Product, and Real Net National Product, Chained Dollars
## 33:              Table 1.7.6. Relation of Real Gross Domestic Product, Real Gross National Product, and Real Net National Product, Chained Dollars
## 34: Table 1.17.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates
## 35: Table 1.17.1. Percent Change From Preceding Period in Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates
## 36:                                                   Table 1.17.5. Gross Domestic Product, Gross Domestic Income, and Other Major NIPA Aggregates
## 37:                                                   Table 1.17.5. Gross Domestic Product, Gross Domestic Income, and Other Major NIPA Aggregates
## 38:                        Table 1.17.6. Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates, Chained Dollars
## 39:                        Table 1.17.6. Real Gross Domestic Product, Real Gross Domestic Income, and Other Major NIPA Aggregates, Chained Dollars
## 40:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 41:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 42:                                                                                                  Table 9.2U. Final Sales of Domestic Computers
## 43:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 44:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 45:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
## 46:                                                                                 Table 9.3U. Gross Domestic Product and Final Sales of Software
##                                                                                                                                          TableName
##             ReleaseDate     NextReleaseDate         MetaDataUpdated  Account
##  1: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  2: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  3: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  4: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  5: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  6: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  7: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  8: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
##  9: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 10: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 11: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 12: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 13: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 14: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 15: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 16: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 17: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 18: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 19: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:29.923 National
## 20: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:29.923 National
## 21: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:29.923 National
## 22: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:29.923 National
## 23: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:29.923 National
## 24: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 25: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 26: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 27: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 28: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 29: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 30: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 31: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 32: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 33: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 34: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 35: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 36: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 37: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 38: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 39: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 40: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 41: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 42: Feb 28 2019  8:30AM Mar 28 2019  8:30AM 2019-03-06T10:13:32.840 National
## 43: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:32.840 National
## 44: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:32.840 National
## 45: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:32.840 National
## 46: Jul 31 2018  8:30AM Jan  1 1900 12:00AM 2019-03-06T10:13:32.840 National
##             ReleaseDate     NextReleaseDate         MetaDataUpdated  Account
##                                                                                                                            apiCall
##  1:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10111', ...))
##  2:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10111', ...))
##  3:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10701', ...))
##  4:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10701', ...))
##  5:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10701', ...))
##  6:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10705', ...))
##  7:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10705', ...))
##  8:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10705', ...))
##  9:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10706', ...))
## 10:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T10706', ...))
## 11:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11701', ...))
## 12:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11701', ...))
## 13:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11705', ...))
## 14:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11705', ...))
## 15:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11706', ...))
## 16:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'T11706', ...))
## 17:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90200', ...))
## 18:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90200', ...))
## 19:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90200', ...))
## 20:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90300', ...))
## 21:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90300', ...))
## 22:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90300', ...))
## 23:               beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIPA', 'TableName' = 'U90300', ...))
## 24: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10111', ...))
## 25: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10111', ...))
## 26: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10701', ...))
## 27: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10701', ...))
## 28: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10701', ...))
## 29: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10705', ...))
## 30: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10705', ...))
## 31: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10705', ...))
## 32: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10706', ...))
## 33: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T10706', ...))
## 34: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11701', ...))
## 35: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11701', ...))
## 36: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11705', ...))
## 37: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11705', ...))
## 38: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11706', ...))
## 39: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'T11706', ...))
## 40: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90200', ...))
## 41: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90200', ...))
## 42: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90200', ...))
## 43: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90300', ...))
## 44: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90300', ...))
## 45: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90300', ...))
## 46: beaGet(list('UserID' = '[your_key]', 'Method' = 'GetData', 'DatasetName' = 'NIUnderlyingDetail', 'TableName' = 'U90300', ...))
##                                                                                                                            apiCall
beadata <- beaGet(list('UserID' = beaKey ,
                       'Method' = 'GetData',
                       'DatasetName' = 'NIPA',
                       'TableName' = 'T10705',
                       'Frequency' = 'A',
                       'Year' = 'X'
                       ))
## No encoding supplied: defaulting to UTF-8.
head(beadata)
##    TableName SeriesCode LineNumber
## 1:    T10705     A191RC          1
## 2:    T10705     B645RC          2
## 3:    T10705     A655RC          3
## 4:    T10705     A001RC          4
## 5:    T10705     A262RC          5
## 6:    T10705     A024RC          6
##                                     LineDescription     METRIC_NAME CL_UNIT
## 1:                     Gross domestic product (GDP) Current Dollars   Level
## 2: Plus: Income receipts from the rest of the world Current Dollars   Level
## 3:   Less: Income payments to the rest of the world Current Dollars   Level
## 4:                   Equals: Gross national product Current Dollars   Level
## 5:               Less: Consumption of fixed capital Current Dollars   Level
## 6:                                          Private Current Dollars   Level
##    UNIT_MULT DataValue_1929 DataValue_1930 DataValue_1931 DataValue_1932
## 1:         6         104556          92160          77391          59522
## 2:         6           1140           1041            767            528
## 3:         6            374            332            252            164
## 4:         6         105322          92869          77906          59886
## 5:         6          10409          10217           9514           8338
## 6:         6           9411           9221           8550           7465
##    DataValue_1933 DataValue_1934 DataValue_1935 DataValue_1936 DataValue_1937
## 1:          57154          66800          74241          84830          93003
## 2:            438            438            522            570            728
## 3:            138            159            181            308            359
## 4:          57454          67079          74582          85092          93372
## 5:           8012           8430           8480           8801           9767
## 6:           7042           7288           7324           7509           8371
##    DataValue_1938 DataValue_1939 DataValue_1940 DataValue_1941 DataValue_1942
## 1:          87352          93437         102899         129309         165952
## 2:            640            683            610            731            708
## 3:            261            310            330            315            297
## 4:          87731          93810         103179         129725         166363
## 5:          10042          10103          10577          12062          14911
## 6:           8580           8590           8976           9950          11246
##    DataValue_1943 DataValue_1944 DataValue_1945 DataValue_1946 DataValue_1947
## 1:         203084         224447         228007         227535         249616
## 2:            699            758            756           1092           1597
## 3:            368            434            491            440            487
## 4:         203415         224771         228272         228187         250726
## 5:          18031          21341          23107          25690          29121
## 6:          11539          12038          12507          14247          17735
##    DataValue_1948 DataValue_1949 DataValue_1950 DataValue_1951 DataValue_1952
## 1:         274468         272475         299827         346914         367341
## 2:           2031           1944           2186           2756           2857
## 3:            575            664            746            864            872
## 4:         275924         273755         301267         348806         369326
## 5:          31326          32284          33394          37726          40606
## 6:          20820          22590          24334          27746          29544
##    DataValue_1953 DataValue_1954 DataValue_1955 DataValue_1956 DataValue_1957
## 1:         389218         390549         425478         449353         474039
## 2:           2843           3039           3507           3933           4268
## 3:            944            944           1058           1137           1213
## 4:         391117         392644         427927         452149         477093
## 5:          43488          45981          48893          54127          58919
## 6:          31344          32958          34995          38811          42259
##    DataValue_1958 DataValue_1959 DataValue_1960 DataValue_1961 DataValue_1962
## 1:         481229         521654         542382         562209         603922
## 2:           3869           4269           4888           5307           5940
## 3:           1241           1508           1775           1788           1847
## 4:         483858         524415         545494         565728         608015
## 5:          62454          65445          67901          70604          74100
## 6:          44910          46819          48209          49781          51795
##    DataValue_1963 DataValue_1964 DataValue_1965 DataValue_1966 DataValue_1967
## 1:         637450         684460         742289         813414         859959
## 2:           6530           7239           7881           8071           8682
## 3:           2053           2319           2602           3001           3289
## 4:         641927         689380         747568         818484         865352
## 5:          78018          82390          88008          95311         103557
## 6:          54158          57276          61568          67172          73327
##    DataValue_1968 DataValue_1969 DataValue_1970 DataValue_1971 DataValue_1972
## 1:         940651        1017615        1073303        1164850        1279110
## 2:          10102          11779          12833          14011          16278
## 3:           4017           5664           6440           6417           7720
## 4:         946736        1023730        1079696        1172444        1287668
## 5:         113357         124896         136839         148926         161011
## 6:          80603          89433          98260         107635         117493
##    DataValue_1973 DataValue_1974 DataValue_1975 DataValue_1976 DataValue_1977
## 1:        1425376        1545243        1684904        1873412        2081826
## 2:          23541          29820          28024          32363          37200
## 3:          10922          14300          15020          15516          16908
## 4:        1437994        1560763        1697908        1890259        2102118
## 5:         178686         206894         238510         260226         289832
## 6:         131492         153159         178790         196512         221127
##    DataValue_1978 DataValue_1979 DataValue_1980 DataValue_1981 DataValue_1982
## 1:        2351599        2627333        2857307        3207041        3343789
## 2:          46252          68321          79092          92024         100993
## 3:          24671          36390          44907          59089          64483
## 4:        2373180        2659264        2891492        3239976        3380299
## 5:         327196         373882         428432         487231         536963
## 6:         252115         290733         334977         381932         420392
##    DataValue_1983 DataValue_1984 DataValue_1985 DataValue_1986 DataValue_1987
## 1:        3634038        4037613        4338979        4579631        4855215
## 2:         101882         121865         112662         111324         123286
## 3:          64797          85575          87297          94367         105798
## 4:        3671122        4073903        4364344        4596588        4872702
## 5:         562624         598394         640137         685295         730385
## 6:         438788         463516         496410         531572         566309
##    DataValue_1988 DataValue_1989 DataValue_1990 DataValue_1991 DataValue_1992
## 1:        5236438        5641580        5963144        6158129        6520327
## 2:         152116         177699         188847         168363         152052
## 3:         129459         152909         154155         136777         120975
## 4:        5259095        5666369        5997836        6189716        6551404
## 5:         784496         838258         888532         932393         960247
## 6:         607913         649619         688396         721456         742886
##    DataValue_1993 DataValue_1994 DataValue_1995 DataValue_1996 DataValue_1997
## 1:        6858559        7287236        7639749        8073122        8577552
## 2:         155600         184543         229833         246404         280071
## 3:         124442         161577         201881         215535         256771
## 4:        6889717        7310202        7667701        8103991        8600853
## 5:        1003498        1055610        1122381        1175306        1239325
## 6:         778210         822507         880728         929111         987753
##    DataValue_1998 DataValue_1999 DataValue_2000 DataValue_2001 DataValue_2002
## 1:        9062817        9631172       10250952       10581929       10929108
## 2:         286779         324646         390638         339642         335811
## 3:         269368         293742         352157         289278         290017
## 4:        9080228        9662075       10289432       10632293       10974902
## 5:        1309737        1398934        1511225        1599511        1657976
## 6:        1052165        1132208        1231511        1311709        1361815
##    DataValue_2003 DataValue_2004 DataValue_2005 DataValue_2006 DataValue_2007
## 1:       11456450       12217196       13039197       13815583       14474228
## 2:         377405         464696         569269         702621         850184
## 3:         318909         387983         494469         656161         754520
## 4:       11514946       12293909       13113997       13862043       14569892
## 5:        1719081        1821828        1971024        2124124        2252806
## 6:        1411949        1497111        1622603        1751800        1852499
##    DataValue_2008 DataValue_2009 DataValue_2010 DataValue_2011 DataValue_2012
## 1:       14769862       14478067       15048970       15599731       16253970
## 2:         855223         689256         759969         827868         827438
## 3:         710009         539013         554336         589936         594681
## 4:       14915076       14628309       15254603       15837664       16486727
## 5:        2358842        2371476        2390926        2474467        2575995
## 6:        1931823        1928709        1933775        1997313        2082378
##    DataValue_2013 DataValue_2014 DataValue_2015 DataValue_2016 DataValue_2017
## 1:       16843196       17550687       18206023       18695106       19477337
## 2:         847233         881582         860759         893475        1031102
## 3:         616935         646356         640376         661531         738153
## 4:       17073493       17785914       18426407       18927050       19770286
## 5:        2681218        2815026        2911385        2987071        3118724
## 6:        2176569        2298472        2388479        2459936        2576755
##    DataValue_2018 DataValue_2019 DataValue_2020 DataValue_2021 DataValue_2022
## 1:       20533058       21380976       21060474       23315081       25461339
## 2:        1138659        1172200         971295        1086987             NA
## 3:         848352         894150         774325         913897             NA
## 4:       20823364       21659027       21257444       23488172             NA
## 5:        3275618        3436609        3577770        3831587        4284265
## 6:        2710537        2850090        2971829        3184502        3567807
beadatatwo <- beaGet(list('UserID' = beaKey ,
                       'Method' = 'GetData',
                       'DatasetName' = 'NIPA',
                       'TableName' = 'T10705',
                       'Frequency' = 'A',
                       'Year' = 'X'
                       ),
                     asWide = FALSE)
## No encoding supplied: defaulting to UTF-8.

Plotting the Graph

library(ggplot2)

beadatathree <- beadata[-(2:34),]

?pivot_longer
beadatathree_long <- pivot_longer(beadatathree, cols =8:101,                
                                  names_to = "year", 
                                  values_to = "GDP"
                                  )
beadatathree_long
## # A tibble: 94 × 9
##    TableName SeriesCode LineNumber LineDe…¹ METRI…² CL_UNIT UNIT_…³ year     GDP
##    <chr>     <chr>      <chr>      <chr>    <chr>   <chr>   <chr>   <chr>  <dbl>
##  1 T10705    A191RC     1          Gross d… Curren… Level   6       Data… 104556
##  2 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  92160
##  3 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  77391
##  4 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  59522
##  5 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  57154
##  6 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  66800
##  7 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  74241
##  8 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  84830
##  9 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  93003
## 10 T10705    A191RC     1          Gross d… Curren… Level   6       Data…  87352
## # … with 84 more rows, and abbreviated variable names ¹​LineDescription,
## #   ²​METRIC_NAME, ³​UNIT_MULT
?ggplot
plot <- ggplot(beadatathree_long, aes(x=year,y=GDP),na.rm = TRUE) + 
        geom_point(color = "lightblue", size = 2) +
        labs(title= "US GDP Growth", 
             x = "Years", 
             y = "GDP") +
        theme(axis.text.x = element_text(angle = 30, hjust = 0.5, vjust = 0.5))
    
plot

Conclusion

GDP dropped during Covid and the 2008 crisis because of lower economic activity overall and lower purchasing power due to people not having extra money for consumption.