Type: | Package |
Title: | A Minimal Tool Set for Gathering USDA Quick Stat Data for Analysis and Visualization |
Version: | 0.4.1 |
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. |
License: | MIT + file LICENSE |
URL: | https://bradlindblad.github.io/tidyUSDA/, https://github.com/bradlindblad/tidyUSDA/ |
Depends: | R (≥ 3.6) |
Imports: | checkmate, crayon, dplyr, fuzzyjoin (≥ 0.1.6), ggplot2, httr, jsonlite, magrittr, sf, tigris (≥ 1.0) |
Suggests: | covr, knitr, nlme, rmarkdown, spelling, stringi, testthat (≥ 2.1.0), usethis, waldo |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
Language: | en-US |
LazyData: | true |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Packaged: | 2023-10-25 02:14:44 UTC; brad |
Author: | Brad Lindblad [aut, cre], Michael Thomas [ctb], Alex Mindeman [ctb] |
Maintainer: | Brad Lindblad <me@bradlindblad.com> |
Repository: | CRAN |
Date/Publication: | 2023-10-25 04:20:02 UTC |
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 me@bradlindblad.com
Other contributors:
Michael Thomas mthomas@ketchbrookanalytics.com [contributor]
Alex Mindeman alexandramindeman@gmail.com [contributor]
See Also
Useful links:
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling 'rhs(lhs)'.
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)