Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bea2Tab

Convert BEA API httr response or list payload to data.table


Description

Convert BEA API httr response or list payload to data.table. Also, converts LONG data frame (default API format - see bea2List results) to WIDE data (with years as columns) by default

Usage

bea2Tab(beaPayload, asWide = TRUE, iTableStyle = TRUE)

Arguments

beaPayload

An object of class 'list' or httr 'response' returned from beaGet() call to BEA API

asWide

Return data.table in wide format (default: TRUE)

iTableStyle

If "asWide = TRUE", setting "iTableStyle = TRUE" will return data.table in same format as shown on BEA website, with dates and attributes as column headers and series as rows; otherwise, results have series codes as column headers (default: TRUE)

Value

An object of class 'data.table' containing data from beaGet(...) with custom attributes(BDT)$params.

Examples

userSpecList <- list('UserID' = 'yourKey' ,
								'Method' = 'GetData',
								'datasetname' = 'NIPA',
								'Frequency' = 'A',
								'TableID' = '68',
								'Year' = 'X')
resp <- beaGet(userSpecList)
BDT <- bea2Tab(resp)

bea.R

Bureau of Economic Analysis API

v1.0.6
CC0
Authors
Andrea Batch [aut, cre], Jeff Chen [ctb], Walt Kampas [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.