Package 'tidyUSDA'

Title: A Minimal Tool Set for Gathering USDA Quick Stat Data for Analysis and Visualization
Description: Provides a consistent API to pull United States Department of Agriculture census and survey data from the National Agricultural Statistics Service (NASS) QuickStats service.
Authors: Brad Lindblad [aut, cre], Michael Thomas [ctb], Alex Mindeman [ctb]
Maintainer: Brad Lindblad <[email protected]>
License: MIT + file LICENSE
Version: 0.4.1.9000
Built: 2024-12-31 05:33:57 UTC
Source: https://github.com/bradlindblad/tidyusda

Help Index


All possible values from the CATEGORY field.

Description

All possible values from the CATEGORY field.

Usage

allCategory

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the COMMODITY field.

Description

All possible values from the COMMODITY field.

Usage

allCommodity

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the COUNTY field.

Description

All possible values from the COUNTY field.

Usage

allCounty

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the DATA ITEM field.

Description

All possible values from the DATA ITEM field.

Usage

allDataItem

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the DOMAIN field.

Description

All possible values from the DOMAIN field.

Usage

allDomain

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the GEOGRAPHY LEVEL field.

Description

All possible values from the GEOGRAPHY LEVEL field.

Usage

allGeogLevel

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the GROUP field.

Description

All possible values from the GROUP field.

Usage

allGroup

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the PROGRAM field.

Description

All possible values from the PROGRAM field.

Usage

allProgram

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the SECTOR field.

Description

All possible values from the SECTOR field.

Usage

allSector

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


All possible values from the STATE field.

Description

All possible values from the STATE field.

Usage

allState

Format

A vector with 1 variable

Source

https://quickstats.nass.usda.gov


getQuickstat

Description

Get values from USDA Quick Stats in a dataframe with optional sf (simple features) geometry field

Usage

getQuickstat(
  key = NULL,
  program = NULL,
  data_item = NULL,
  sector = NULL,
  group = NULL,
  commodity = NULL,
  category = NULL,
  domain = NULL,
  geographic_level = NULL,
  state = NULL,
  county = NULL,
  year = NULL,
  geometry = FALSE,
  lower48 = FALSE,
  weighted_by_area = FALSE
)

Arguments

key

your USDA api key. Get one at https://quickstats.nass.usda.gov/api - string

program

program field - string

data_item

data_item field - string

sector

sector field - string

group

group field - string

commodity

commodity field - string

category

category field - string

domain

domain field - string

geographic_level

geographic_level field - string

state

state field - either a string or character vector with multiple states

county

county field - either a string or character vector with multiple states

year

year field - string

geometry

geometry field (TRUE or FALSE), set to TRUE if you would like a simple features (SF) geometry field included. Only works when geographic_level is set to 'COUNTY' or 'STATE'

lower48

limit data to the lower 48 states? - TRUE or FALSE

weighted_by_area

option to mutate a new column that takes the target ('Value') and divides it by the square miles in that state or county; only works when GEOMETRY = TRUE - TRUE or FALSE

Note

Go to the webpage https://quickstats.nass.usda.gov/. As a best practice, select the items in these fields and test that that data item exists in the browser before using those parameters in this function. When you have a dataset that works, enter those values in the function as parameters. Ideally, only enter values for your key obviously, then PROGRAM, DATA_ITEM, GEOGRAPHIC_LEVEL and then if necessary, DOMAIN, STATE, COUNTY or YEAR.

Examples

## Not run: 
getQuickstat(
  key = "your_key",
  program = "CENSUS",
  data_item = "CROP TOTALS - OPERATIONS WITH SALES",
  geographic_level = "COUNTY",
  domain = "TOTAL",
  year = "2017",
  state = NULL,
  geometry = T,
  lower48 = T
)

## End(Not run)

plotUSDA

Description

Quickly plot a data frame produced by the getQuickstat() function.

Usage

plotUSDA(df, fill_by = "Value")

Arguments

df

a data frame with a simple feature column (geometry)

fill_by

the value you would like to fill your choropleth output

Examples

## Not run: 
# Use output from getQuickstat()
plotUSDA(df = df_from_getQuickstat)

## End(Not run)

tidyUSDA: An Interface to USDA QuickStats Data with Mapping Capabilities.

Description

A minimal toolset for gathering USDA Quick Stat data for analysis and visualization.

Author(s)

Maintainer: Brad Lindblad [email protected]

Other contributors:

See Also

Useful links: