library(blsAPI)
library(rjson)
payload1 <- list(
'seriesid'='LAUCN040010000000005',
'startyear'=2010,
'endyear'=2012,
'catalog'=FALSE,
'calculations'=TRUE, # Here it's TRUE
'annualaverage'=FALSE,
'registrationKey'=Sys.getenv("BLS_REG_KEY"))
response1 <- blsAPI(payload1, 2)
json1 = fromJSON(response1)
payload2 <- list(
'seriesid'='LAUCN040010000000005',
'startyear'=2010,
'endyear'=2012,
'catalog'=FALSE,
'calculations'=FALSE, # Here it's FALSE
'annualaverage'=FALSE,
'registrationKey'=Sys.getenv("BLS_REG_KEY"))
response2 <- blsAPI(payload2, 2)
json2 = fromJSON(response2)
apiDF <- function(data){
df <- data.frame(year=character(),
period=character(),
periodName=character(),
value=character(),
stringsAsFactors=FALSE)
i <- 0
for(d in data){
i <- i + 1
df[i,] <- unlist(d)
}
return(df)
}
unemployed.df1 <- apiDF(json1$Results$series[[1]]$data)
unemployed.df2 <- apiDF(json2$Results$series[[1]]$data)
identical(unemployed.df1, unemployed.df2)
# [1] TRUE
When I set
'calculations'=TRUEin the payload, and then use it to callblsAPI(), the response does not contain net or percent changes. Thevaluecolumn contains the same values as it does when I callblsAPI()with'calculations'=FALSE. See the following:Am I doing something wrong?