Skip to content

GetQuickStats() question: Handling Redacted or Missing value like (D) or NA #65

@adacurro-usgs

Description

@adacurro-usgs

Hello,

I've noticed that when using getQuickStats() from this package, the Value column returns NA regardless whether the value is redacted (D) or Not Available (NA). I'm curious about how these values are being handled internally.

Issue

  • Redacted values such as (D) ( to avoid disclosing individual operations) and NA (Not Available) are automatically converted to NA
  • This makes it difficult to distinguish between truly missing data and intentionally redacted data in downstream analysis.

Questions

  • Does getQuickStats() parse the API response and convert Values with non-numeric values to NA, regardless of whether it's (D) or NA?
  • Is there a way (or could there be an option) to preserve the original USDA suppression code in the Value column, e.g. keep (D) or NA as character values instead of coercing them to NA?

Preserving this information would be useful for analysis that accounts for estimating animal counts

Code Example:

dairycows <- getQuickstat(key = NASS_API_KEY, program = "CENSUS", data_item = "CATTLE, COWS, MILK - INVENTORY", sector = "ANIMALS & PRODUCTS", domain = "TOTAL", geographic_level = "COUNTY", state = NULL, year = <YEAR_HEEE>, geometry = FALSE, lower48 = F # weighted_by_area = FALSE )

Example result:

The image on the left is our Exported Data and on the right is the download data from https://quickstats.nass.usda.gov/
Image

The highlighted rows are the exact match for both dataset. The downloaded data from usda.gov returns (D) or redacted as oppose to the data generate by getQuickStats()

Thank you so much!

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