Skip to content

Data incorrect when pulling multiple cities #40

@robertv4311

Description

@robertv4311

I have run into an odd error. When I pull numbers for a single city they are correct and match the BLS website. However, when I combine 25 cities and pull them all at once, the numbers appear to be scrambled or otherwise somehow wrong.

An example showing the unemployment rate for NYC is correct when pulled alone but different when pulled as the first in a group of cities (make sure to add your key or switch to 1):

require(blsAPI)
require(tidyverse)

bigcities <- c("New York city, NY", "Los Angeles city, CA", "Chicago city, IL", "Houston city, TX", "Phoenix city, AZ", "San Antonio city, TX", "San Diego city, CA", "Dallas city, TX", "San Jose city, CA", "Austin city, TX", "Jacksonville city, FL", "Fort Worth city, TX", "Columbus city, OH", "Charlotte city, NC", "Seattle city, WA", "Washington city, DC", "Boston city, MA", "El Paso city, TX", "Detroit city, MI", "Oklahoma City city, OK", "Portland city, OR", "Las Vegas city, NV", "North Las Vegas city, NV", "Memphis city, TN", "Baltimore city, MD")

laus_get_data(location.vector = bigcities, 
+               measure.vector = "unemployment rate", 
+               start.year = 2018, end.year = 2023, 
+               api.version = 2, bls.key = "PUT YOUR KEY HERE") |> head()

For the combined list the output begins with:

  year period periodName Unemployment_Rate          Location
1 2023    M12   December               2.9 New York city, NY
2 2023    M11   November               2.9 New York city, NY
3 2023    M10    October               3.2 New York city, NY
4 2023    M09  September               2.8 New York city, NY
5 2023    M08     August               3.1 New York city, NY
6 2023    M07       July               2.9 New York city, NY

But when I just pull NYC:

laus_get_data(location.vector = "New York city, NY", 
+               measure.vector = "unemployment rate", 
+               start.year = 2018, end.year = 2023, 
+               api.version = 2, bls.key = "PUT YOUR KEY HERE") |> head()

The output is then:

  year period periodName Unemployment_Rate          Location
1 2023    M12   December               5.1 New York city, NY
2 2023    M11   November               4.9 New York city, NY
3 2023    M10    October               5.4 New York city, NY
4 2023    M09  September               5.1 New York city, NY
5 2023    M08     August               5.6 New York city, NY
6 2023    M07       July               5.3 New York city, NY

In December 2023, New York City had an unemployment rate of 5.1, not 2.9, in series LAUCT365100000000003, so the first, combined one, appears to be wrong.

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