Created
May 28, 2019 20:07
-
-
Save potterzot/757219e35ee84035d002d69a0f8bc133 to your computer and use it in GitHub Desktop.
Fetching PCT PLANTED and YIELD for corn from USDA-NASS QuickStats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Fetch % planted and yield from NASS QUICKSTATS | |
# | |
# Requires the rnassqs `R` package: https://github.com/potterzot/rnassqs | |
# Need to get an API KEY here: https://quickstats.nass.usda.gov/api | |
api_key <- Sys.getenv("NASSQS_TOKEN") | |
## First get PCT PLANTED | |
# Define the parameters to fetch PCT PLANTED | |
pct_planted_params <- list( | |
commodity_desc = "CORN", | |
agg_level_desc = "STATE", | |
statisticcat_desc = "PROGRESS", | |
unit_desc = "PCT PLANTED" | |
) | |
# Number of records must be less than 50000 | |
rnassqs::nassqs_record_count(pct_planted_params) | |
# Fetch the data | |
pct_planted <- rnassqs::nassqs(pct_planted_params, key = api_key) | |
## Get YIELD | |
yield_params <- list( | |
commodity_desc = "CORN", | |
agg_level_desc = "STATE", | |
statisticcat_desc = "YIELD", | |
unit_desc = "BU / ACRE", | |
year = "2017" | |
) | |
rnassqs::nassqs_record_count(yield_params) | |
yield <- rnassqs::nassqs(yield_params, key = api_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment