Skip to content

'calulations'=TRUE doesn't return net and percent changes #26

Description

@SteadyGiant

When I set 'calculations'=TRUE in the payload, and then use it to call blsAPI(), the response does not contain net or percent changes. The value column contains the same values as it does when I call blsAPI() with 'calculations'=FALSE. See the following:

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 

Am I doing something wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions