Title: | Access Data from the USDA ARMS Data API |
---|---|
Description: | Interface to easily access data via the United States Department of Agriculture (USDA)'s Agricultural Resource Management Survey (ARMS) Data API <https://www.ers.usda.gov/developer/data-apis/arms-data-api/>. The downloaded data can be saved for later off-line use. Also provide relevant information and metadata for each of the input variables needed for sending the data inquery. |
Authors: | Bowen Chen [aut, cre] , Benjamin Gramig [ctb] |
Maintainer: | Bowen Chen <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0 |
Built: | 2024-12-24 02:41:16 UTC |
Source: | https://github.com/cbw1243/rarms |
The primary function in the rarms
package to send request to the USDA ARMS Data API.
armsRequest( state = NULL, year, category = NULL, report = NULL, variable = NULL, farmtype = NULL )
armsRequest( state = NULL, year, category = NULL, report = NULL, variable = NULL, farmtype = NULL )
state |
optional character vector. It can be full state names, or state id, or state code. Use NULL if for all states. |
year |
numerical/character vector. Which year(s) to request? This is required. |
category |
optional character vector. Category names or IDs. |
report |
optional vector. Report names or IDs. |
variable |
optional vector. Variable names or IDs. |
farmtype |
optional vector. Farm type or ID. |
An API key is needed for sending the data requests. To apply for a key, go to this website: https://www.ers.usda.gov/developer/. Then click Register.
To make valid request, users should provide valid values for the input variables (e.g., report). Users can refer to this
USDA website for information on the input variables (https://www.ers.usda.gov/developer/data-apis/arms-data-api/).
Users can also use paramSearch
in the package to get possible valid values for each input variable (see examples in paramSearch
).
For most input variables, users can use id or codes instead of original names to simplify the requests. For example, the id and code for Arkansas is 05 and ar, respectively. Users can let state = '05' or state = 'ar' to request data for Arkansas instead of letting state = 'Arkansas'. Similarily, the id for the report named Farm Business Balance Sheet is 1, users can simply let report = 1 to request data from this report.
The function returns a list with three elements: (1) request status, (2) request information, (3) the requested data.
## Not run: key <- 'Your key' # Specify your API key here. test <- armsRequest(year = c(2005:2018), state = c('05', '06'), category = c('age', 'ftyppl'), report = c(1, 2), variable = c('kount', 'accrop'), farmtype = 'all farms') data <- test$data # Get the data returned from the ARMS data API. ## End(Not run)
## Not run: key <- 'Your key' # Specify your API key here. test <- armsRequest(year = c(2005:2018), state = c('05', '06'), category = c('age', 'ftyppl'), report = c(1, 2), variable = c('kount', 'accrop'), farmtype = 'all farms') data <- test$data # Get the data returned from the ARMS data API. ## End(Not run)
Return values of the selected input variables
paramSearch(param)
paramSearch(param)
param |
Name of input variable |
A data set that contains possible values of the selected input variable.
## Not run: key <- 'Your key' # Specify your API key here. paramSearch(param = 'state') paramSearch(param = 'year') paramSearch(param = 'category') ## End(Not run)
## Not run: key <- 'Your key' # Specify your API key here. paramSearch(param = 'state') paramSearch(param = 'year') paramSearch(param = 'category') ## End(Not run)