The primary function in the rnassqs package, nassqs makes a HTTP GET request to the USDA-NASS Quick Stats API and returns the data parsed as a data.frame, plain text, or list. Various other functions make use of nassqs to make specific queries. For a data request the Quick Stats API returns JSON that when parsed to a data.frame contains 39 columns and a varying number of rows depending on the query. Unfortunately there is not a way to restrict the number of columns.

  source_desc = NULL,
  sector_desc = NULL,
  group_desc = NULL,
  commodity_desc = NULL,
  short_desc = NULL,
  domain_desc = NULL,
  domaincat_desc = NULL,
  agg_level_desc = NULL,
  statisticcat_desc = NULL,
  state_name = NULL,
  asd_desc = NULL,
  county_name = NULL,
  region_desc = NULL,
  zip_5 = NULL,
  watershed_desc = NULL,
  year = NULL,
  freq_desc = NULL,
  reference_period_desc = NULL,
  as = c("data.frame", "text", "list")



either a named list of parameters or a series of parameters to form the query


"Program" - Source of data ("CENSUS" or "SURVEY"). Census program includes the Census of Ag as well as follow up projects. Survey program includes national, state, and county surveys.


"Sector" - Five high level, broad categories useful to narrow down choices. ("ANIMALS & PRODUCTS", "CROPS", "DEMOGRAPHICS", "ECONOMICS", or "ENVIRONMENTAL")


"Group" - Subsets within sector (e.g., under sector_desc = "CROPS", the groups are "FIELD CROPS", "FRUIT & TREE NUTS", "HORTICULTURE", and "VEGETABLES").


"Commodity" - The primary subject of interest (e.g., "CORN", "CATTLE", "LABOR", "TRACTORS", "OPERATORS").


"Data Item" - A concatenation of six columns: commodity_desc, class_desc, prodn_practice_desc, util_practice_desc, statisticcat_desc, and unit_desc.


"Domain" - Generally another characteristic of operations that produce a particular commodity (e.g., "ECONOMIC CLASS", "AREA OPERATED", "NAICS CLASSIFICATION", "SALES"). For chemical usage data, the domain describes the type of chemical applied to the commodity. The domain_desc = "TOTAL" will have no further breakouts; i.e., the data value pertains completely to the short_desc.


"Domain Category" - Categories or partitions within a domain (e.g., under domain_desc = "SALES", domain categories include $1,000 TO $9,999, $10,000 TO $19,999, etc).


"Geographic Level" - Aggregation level or geographic granularity of the data. ("AGRICULTURAL DISTRICT", "COUNTY", "INTERNATIONAL", "NATIONAL", "REGION : MULTI-STATE", "REGION : SUB-STATE", "STATE", "WATERSHED", or "ZIP CODE")


"Category" - The aspect of a commodity being measured (e.g., "AREA HARVESTED", "PRICE RECEIVED", "INVENTORY", "SALES").


"State" - State full name.


"Ag District" - Ag statistics district name.


"County" - County name.


"Region" - NASS defined geographic entities not readily defined by other standard geographic levels. A region can be a less than a state (SUB-STATE) or a group of states (MULTI-STATE), and may be specific to a commodity.


"Zip Code" - US Postal Service 5-digit zip code.


"Watershed" - Name assigned to the HUC.


"Year" - The numeric year of the data and can be either a character or numeric vector. Conditional values are also possible, for example a character vector of ">=1999" of "1999<=" will give years greater than or equal to 1999. Right now the logical values can either be greater/less than or equal to with the logical at either the beginning or end of a string with the year.


"Period Type" - Length of time covered ("ANNUAL", "SEASON", "MONTHLY", "WEEKLY", "POINT IN TIME"). "MONTHLY" often covers more than one month. "POINT IN TIME" is as of a particular day.


"Period" - The specific time frame, within a freq_desc.


whether to return a data.frame, list, or text string nassqs_GET()


a data frame, list, or text string of requested data.

See also


# \donttest{ # Get corn yields in Virginia in 2012 params <- list(commodity_desc = "CORN", year = 2012, agg_level_desc = "COUNTY", state_alpha = "VA", statisticcat_desc = "YIELD") yields <- nassqs(params)
#> Error in expand_list(params): could not find function "expand_list"
#> Error in head(yields): object 'yields' not found
# }