Description Usage Arguments Examples
View source: R/getNassAPI_funs.R
Downloads NASS crop data by requested county, program source, and short desc
1 2 | getNassCounty_short(apiKey, program, shortDesc, state, county,
year = 1996)
|
apiKey |
Personal key; Obtained from http://quickstats.nass.usda.gov/api |
program |
'CENSUS' or 'SURVEY' |
shortDesc |
short description of desired data field; aka 'Data Item' |
state |
state 2 digit fips |
county |
county 3-digit ANSI code. To get all counties in state, set to NA. |
year |
year to start getting data - gets all subsequent years. default is 1996 to get all Census |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # set up variables for data calls
apiKey <- '28EAA9E6-8062-34A4-981A-B2ED4692228A' # my code, modified
program = 'CENSUS'
shortDesc <- 'AG LAND, CROPLAND - ACRES'
state <- '08'
county <- '001'
# simple example
oneCounty <- getNassCounty(apiKey, program, shortDesc, state, county)
# data frame of states and counties:
# make empty list to populate, and loop through counties
nass.list <- list()
for(i in 1:nrow(counties)){
nass.list[[i]] <- getNASS(apiKey, program, sector, group, shortDesc, aggregation,
state = counties$abb[i],
county = counties$COUNTYFP[i])
}
# convert list of data frames to 1 giant dataframe
nass.df <- do.call("rbind",nass.list)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.