get_county_data: A flexible function for pulling county-level data.

Description Usage Arguments Value Examples

View source: R/nass_api.R

Description

Automatically builds the specified query and retrieves county-level data.

Usage

1
2
3
4
5
6
7
8
get_county_data(
  key,
  year,
  data_item,
  fips = "all",
  domain = "TOTAL",
  source = "CENSUS"
)

Arguments

key

Your NASS API key.

year

Must be a census year (e.g. 2012, 2017).

data_item

The long description of the desired series. Use search_data_items function to find one.

fips

Must be 'all', a 2-digit state fips, or a 5-digit county fips.

domain

A modifier on data_item, some characterstic (e.g. size categories of operations), use 'all' to get all.

source

Must be 'CENSUS' or 'SURVEY'.

Value

A tibble df of the requested data, if any exists. Otherwise returns NULL.

Examples

1
2
3
4
5
6
7
8
key <- Sys.getenv('NASS_KEY')
get_county_data(key=key, year=2017,
                data_item='CORN, GRAIN - ACRES HARVESTED', fips='all')
get_county_data(key=key, year=2017,
                data_item='CORN, GRAIN - ACRES HARVESTED', fips='08')
get_county_data(key=key, year=2017,
                data_item='CORN, GRAIN - ACRES HARVESTED', fips='08069',
                domain='all')

anderaa/quickerstats documentation built on Oct. 27, 2020, 9:45 p.m.