ams-goonies / usda-hackathon-2024

R Shiny app for visualizing 2022 Ag Census data
GNU General Public License v3.0
0 stars 0 forks source link

Get state-level percentage share of total sales for all commodities #3

Closed elhohn closed 2 months ago

elhohn commented 3 months ago

Preferably, use something like the following:

tidyUSDA::getQuickstat(
  sector = 'CROPS',
  #group = c('FIELD CROPS', 'FRUIT & TREE NUTS', 'VEGETABLES'),
  #commodity='CROP TOTALS',
  category='SALES',
  #domain='SALES & DISTRIBUTION',
  #county=NULL,
  key = ag_census_api_key,
  program = 'CENSUS',
  #data_item = 'CROP TOTALS - SALES, MEASURED in $',
  geographic_level = 'COUNTY',
  year = '2017',
  state = 'ALABAMA',
  geometry = TRUE,
  lower48 = TRUE, 
  weighted_by_area = TRUE) %>%
  filter(grepl("SALES, MEASURED IN", short_desc))

That way, it can be saved in a script and easily reproduced and/or modified.