rm(list=ls()) # remove all objects from environment cat(“) # Clear the console

library(bea.R)
## 载入需要的程辑包:data.table
## 从package 'googleVis'里的程辑包'jsonlite'为'toJSON'建立新的泛型函数
## 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)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2
## ──
## ✔ tibble  3.1.8     ✔ dplyr   1.1.0
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.4     ✔ forcats 1.0.0
## ✔ purrr   1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::between()   masks data.table::between()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::first()     masks data.table::first()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::last()      masks data.table::last()
## ✖ purrr::transpose() masks data.table::transpose()
library(dplyr)  

beaKey <- "414F3C21-8AAE-42F7-B4A0-56CB9AEA89E3"

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 414F3C21-8AAE-42F7-B4A0-56CB9AEA89E3
## 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
## D:/Study/R-4.2.2/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
bea10 <- beaGet(list("UserID" = beaKey, 
                   "Method" = "GetData", 
                   "datasetname" = "NIPA", 
                   "TableName" = "T10705", 
                   "Frequency" = "A", 
                   "Year" = "X"
))
## No encoding supplied: defaulting to UTF-8.
colnames(bea10) <- sub("DataValue_"," ", colnames(bea10))


realGDP <- pivot_longer(data = bea10,
                      cols = 8:101,
                      names_to = "year",
                      values_to = "value"
                      )

realGDP <- realGDP[-c(95:3196), ]

realGDP
## # A tibble: 94 × 9
##    TableName SeriesCode LineNumber LineDe…¹ METRI…² CL_UNIT UNIT_…³ year   value
##    <chr>     <chr>      <chr>      <chr>    <chr>   <chr>   <chr>   <chr>  <dbl>
##  1 T10705    A191RC     1          Gross d… Curren… Level   6       " 19… 104556
##  2 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  92160
##  3 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  77391
##  4 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  59522
##  5 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  57154
##  6 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  66800
##  7 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  74241
##  8 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  84830
##  9 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  93003
## 10 T10705    A191RC     1          Gross d… Curren… Level   6       " 19…  87352
## # … with 84 more rows, and abbreviated variable names ¹​LineDescription,
## #   ²​METRIC_NAME, ³​UNIT_MULT
RealGDPplot <- ggplot(realGDP, 
                      aes( x = year, y = value), 
                      na.rm = TRUE) + 
                      geom_point(color = "#FFC0CB", size = 0.75) + 
  labs(x = "YEAR", y = "GDP(CurrentDollars)") +
  theme(axis.text.x = element_text(angle = 90, hjust = 0.5, vjust = 0.5))
                      
RealGDPplot