Just an FYI that I'm not a professional programmer/researcher and this is my first time using R to pull Census data.
I'm trying to workaround the fact that the Census API isn't designed for pulling full datasets. One of the macro teams at the DOE is interested in collecting and consolidating international trade data by HS and NAICS from the Census.
I talked briefly to a Census supervisor for macro analysis and read through the API guide. Then, I tried to set up an API call in R using the censusapi pkg. Got the following:
What I was trying to do was limit the API call to only the export parameters by string and a handful of int type parameters that fall under a certain category like air, shipping, etc. The Census supervisor advised that I merge calls and filter out the summary lines by including the following: SUMMARY_LVL2=HSCYCSDTRP, COMM_LVL=HS10, and SUMMARY_LVL=DET
I'm not sure if the issue is I'm calling too many variables at once or something else.
x<-c("censusapi", "data.table")
require(x)
lapply(x, require, character.only = TRUE)
apis <- listCensusApis()
View(apis)
example <- listCensusMetadata(name = "timeseries/intltrade/exports/hs", type = "variables")
head(example)
HS.Mon.Exports <- getCensus(name = "timeseries/intltrade/exports/hs",
vars = c("AIR_VAL_MO", "AIR_VAL_YR", "AIR_WGT_MO", "AIR_WGT_YR", "SUMMARY_LVL=DET",
"QTY_1_YR_FLAG", "DIST_NAME", "YEAR", "CTY_NAME", "COMM_LVL=HS10",
"E_COMMODITY_SDESC", "DF", "MONTH", "CTY_CODE", "LAST_UPDATE", "DISTRICT",
"E_COMMODITY_LDESC", "QTY_1_MO_FLAG", "SUMMARY_LVL2=HSCYCSDTRP", "E_COMMODITY",
"UNIT_QY2", "UNIT_QY1", "QTY_2_MO_FLAG", "QTY_2_YR_FLAG",
"E_COMMODITY","UNIT_QY1"), region = "us:*")
head(HS.Mon.Exports)
Let me know if what I'm saying is confusing or unclear. Thank you for your time!