rnassqs

rnassqs: An R package to access agricultural data via the USDA National Agricultural Statistics Service (USDA-NASS) 'Quick Stats' API - Published in JOSS (2019)

https://github.com/ropensci/rnassqs

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    1 of 9 committers (11.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Biochemistry, Genetics and Molecular Biology Life Sciences - 40% confidence
Last synced: 6 months ago · JSON representation

Repository

R interface for the USDA National Agricultural Statistical Service's (NASS) 'Quick Stats' API (https://quickstats.nass.usda.gov/api)

Basic Info
Statistics
  • Stars: 47
  • Watchers: 6
  • Forks: 18
  • Open Issues: 2
  • Releases: 6
Created over 10 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License Codemeta Zenodo

README.Rmd

---
output:
  md_document:
    variant: gfm
---




rnassqs Usage Release Development
rnassqs

(Wheat image from here.)

License CRAN Last Change
downloads Zenodo R CMD Check
Codecov test status
ORCID Project Status: Active – The project has reached a stable, usable state and is being actively developed.
DOI:10.21105/joss.01880 Project Status: Maturing.

__As required by the NASS Terms of Use: This product uses the NASS API but is not endorsed or certified by NASS.__ ## rnassqs (R NASS Quick Stats) `rnassqs` allows users to access the USDA's National Agricultural Statistics Service (NASS) Quick Stats data through their API. It is simple and easy to use, and provides some functions to help navigate the bewildering complexity of some Quick Stats data. For docs and code examples, visit the package web page here: [https://docs.ropensci.org/rnassqs/](https://docs.ropensci.org/rnassqs/). ## Installing Install the package via `devtools` or CRAN: ```{r eval=FALSE} # Via devtools library(devtools) install_github('ropensci/rnassqs') # Via CRAN install.packages("rnassqs") ``` ## API Key To use the NASS Quick Stats API you need an [API key](https://quickstats.nass.usda.gov/api/). The API key should in general not be included in scripts. One way of making the key available without defining it in a script is by setting it in your `.Renviron` file, which is usually located in your home directory. If you are an `rstudio` user, you can use `usethis::edit_r_environ()` to open your `.Renviron` file and add a line that looks like: ```{r eval=FALSE} NASSQS_TOKEN="" ``` Alternatively, you can set it explicitly in the console with `nassqs_auth(key = )`. This will set the environmental variable NASSQS_TOKEN, which is used to access the API. You can also set this directly with `Sys.setenv("NASSQS_TOKEN" = )`. ## Usage See the examples in [inst/examples](inst/examples) for quick recipes to download data. The primary function is `nassqs()`, with which you can make any query of variables. For example, to mirror the request that is on the [NASS API documentation](https://quickstats.nass.usda.gov/api/), you can use: ```{r eval=FALSE} library(rnassqs) # You must set your api key before requesting data nassqs_auth(key = ) # Parameters to query on and data call params <- list(commodity_desc = "CORN", year__GE = 2012, state_alpha = "VA") d <- nassqs(params) ``` Parameters __do not__ need to be capitalized, and also do not need to be in a list format. The following works just as well: ```{r eval=FALSE} d <- nassqs(commodity_desc = "corn", year__GE = 2012, state_alpha = "va") ``` You can request data for multiple values of the same parameter by using a simple list as follows: ```{r eval=FALSE} params <- list(commodity_desc = "CORN", year__GE = 2012, state_alpha = c("VA", "WA")) d <- nassqs(params) ``` NASS does not allow GET requests that pull more than 50,000 records in one request. The function will inform you if you try to do that. It will also inform you if you've requested a set of parameters for which there are no records. Other useful functions include: ```{r eval=FALSE} # returns a set of unnique values for the parameter "STATISTICCAT_DESC" nassqs_param_values("statisticcat_desc") # returns a count of the number of records for a given query nassqs_record_count(params=params) # Get yields specifically # Equivalent to including "'statisticat_desc' = 'YIELD'" in your parameter list. nassqs_yields(params) # Get acres specifically # Equivalent to including all "AREA" values in statisticcat_desc nassqs_acres(params) # Specifies just "AREA HARVESTED" values of statisticcat_desc nassqs_acres(params, area = "AREA HARVESTED") ``` ### Handling inequalities and operators other than "=" The NASS API handles other operators by modifying the variable name. The API can accept the following modifications: * __LE: <= * __LT: < * __GT: > * __GE: >= * __LIKE: like * __NOT_LIKE: not like * __NE: not equal For example, to request corn yields in Virginia and Pennsylvania for all years since 2000, you would use something like: ```{r eval=FALSE} params <- list(commodity_desc = "CORN", year__GE = 2000, state_alpha = c("VA", "PA"), statisticcat_desc = "YIELD") df <- nassqs(params) #returns data as a data frame. ``` See the [vignette](https://docs.ropensci.org/rnassqs/articles/rnassqs.html) for more examples and details on usage. ## Contributing Contributions are more than welcome, and there are several ways to contribute: - Examples: More examples are always helpful. If you use `rnassqs` to query data from 'Quick Stats' and would like to contribute your query, consider submitting a pull request adding your query as a file in [inst/examples/](https://github.com/ropensci/rnassqs/tree/main/inst/examples). - File an issue: If there is functionality you'd like to see added or something that is confusing, consider [creating an issue](https://github.com/ropensci/rnassqs/issues/new). The best issue contains an example of the problem or feature. Consider the excellent package [reprex](https://github.com/tidyverse/reprex) in creating a reproducible example. - Contributing documentation: Clarifying and expanding the documentation is always appreciated, especially if you find an area that is lacking and would like to improve it. `rnassqs` uses roxygen2, which means the documentation is at the top of each function definition. Please submit any improvements as a pull request. - Contributing code: if you see something that needs improving and you'd like to make the changes, contributed code is very welcome. Begin by filing a new issue to discuss the proposed change, and then submit a pull request to address the issue. `rnassqs` follows the style outlined in Hadley Wickham's [R Packages](https://r-pkgs.org/code.html#code-style). Following this style makes the pull request and review go more smoothly. ## Alternatives In June 2019 the `usdarnass` package was released on [CRAN](https://cran.r-project.org/package=usdarnass) and is also available to install via [github](https://github.com/rdinter/usdarnass). `usdarnass` has similar functionality to this package. NASS also provides a daily tarred and gzipped file of their entire dataset. At the time of writing it is approaching 1 GB. You can download that file via their [data site](https://www.nass.usda.gov/datasets/). The FTP link also contains builds for: NASS census (every 5 years ending with 2 and 7), or data for one of their specific sectors (CROPS, ECONOMICS, ANIMALS & PRODUCTS). At the time of this writing, specific files for the ENVIRONMENTAL and DEMOGRAPHICS sectors are not available. ### Acknowledgments Thank you to rOpensci reviewers Adam Sparks and Neal Richardson and editor Lincoln Mullen, for their fantastic feedback and assistance. User feedback and use case contributions have been a huge help to make `rnassqs` more accessible and user-friendly. More use cases or feature requests are always welcome! [![ropensci_footer](https://ropensci.org/public_images/ropensci_footer.png)](https://ropensci.org) ```{r, echo = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" ) ```

Owner

  • Name: rOpenSci
  • Login: ropensci
  • Kind: organization
  • Email: info@ropensci.org
  • Location: Berkeley, CA

JOSS Publication

rnassqs: An R package to access agricultural data via the USDA National Agricultural Statistics Service (USDA-NASS) 'Quick Stats' API
Published
November 17, 2019
Volume 4, Issue 43, Page 1880
Authors
Nicholas A. Potter ORCID
Washington State University
Editor
Kyle Niemeyer ORCID
Tags
API reproducibility agriculture economics

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "rnassqs",
  "description": "Interface to access data via the United States Department of Agriculture's National Agricultural Statistical Service (NASS) 'Quick Stats' web API <https://quickstats.nass.usda.gov/api/>. Convenience functions facilitate building queries based on available parameters and valid parameter values. This product uses the NASS API but is not endorsed or certified by NASS.",
  "name": "rnassqs: Access Data from the NASS 'Quick Stats' API",
  "relatedLink": [
    "https://docs.ropensci.org/rnassqs/",
    "https://CRAN.R-project.org/package=rnassqs"
  ],
  "codeRepository": "https://github.com/ropensci/rnassqs/",
  "issueTracker": "https://github.com/ropensci/rnassqs/issues",
  "license": "https://spdx.org/licenses/MIT",
  "version": "0.6.2",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.3.1 (2023-06-16 ucrt)",
  "author": [
    {
      "@type": "Person",
      "givenName": "Nicholas",
      "familyName": "Potter",
      "email": "econpotter@gmail.com"
    }
  ],
  "contributor": [
    {
      "@type": "Person",
      "givenName": "Robert",
      "familyName": "Dinterman"
    },
    {
      "@type": "Person",
      "givenName": "Jonathan",
      "familyName": "Adams"
    },
    {
      "@type": "Person",
      "givenName": "Joseph",
      "familyName": "Stachelek"
    },
    {
      "@type": "Person",
      "givenName": "Julia",
      "familyName": "Piaskowski"
    },
    {
      "@type": "Person",
      "givenName": "Branden",
      "familyName": "Collingsworth"
    },
    {
      "@type": "Person",
      "givenName": "Neal",
      "familyName": "Richardson"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Nicholas",
      "familyName": "Potter",
      "email": "econpotter@gmail.com"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "here",
      "name": "here"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "httptest",
      "name": "httptest"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat"
    }
  ],
  "softwareRequirements": {
    "1": {
      "@type": "SoftwareApplication",
      "identifier": "httr",
      "name": "httr"
    },
    "2": {
      "@type": "SoftwareApplication",
      "identifier": "jsonlite",
      "name": "jsonlite"
    },
    "3": {
      "@type": "SoftwareApplication",
      "identifier": "stats",
      "name": "stats"
    },
    "4": {
      "@type": "SoftwareApplication",
      "identifier": "utils",
      "name": "utils"
    },
    "SystemRequirements": null
  },
  "fileSize": "2713.931KB",
  "citation": [
    {
      "@type": "ScholarlyArticle",
      "datePublished": "2019",
      "author": [
        {
          "@type": "Person",
          "givenName": [
            "Nicholas",
            "A"
          ],
          "familyName": "Potter"
        }
      ],
      "name": "rnassqs: An `R` package to access agricultural data via the USDA National Agricultural Statistics Service (USDA-NASS) 'Quick Stats' API",
      "isPartOf": {
        "@type": "PublicationIssue",
        "datePublished": "2019",
        "isPartOf": {
          "@type": [
            "PublicationVolume",
            "Periodical"
          ],
          "name": "The Journal of Open Source Software"
        }
      }
    },
    {
      "@type": "SoftwareSourceCode",
      "author": [
        {
          "@type": "Person",
          "givenName": "Nicholas",
          "familyName": "Potter"
        }
      ],
      "name": "{rnassqs}: Access the NASS 'Quick Stats' API",
      "url": "https://CRAN.R-project.org/package=rnassqs",
      "description": "R package version 0.6.2"
    }
  ],
  "releaseNotes": "https://github.com/ropensci/rnassqs/blob/main/NEWS.md",
  "readme": "https://github.com/ropensci/rnassqs/blob/main/README.md",
  "contIntegration": [
    "https://app.travis-ci.com/ropensci/rnassqs",
    "https://app.codecov.io/gh/ropensci/rnassqs"
  ],
  "developmentStatus": [
    "https://www.repostatus.org/#active",
    "https://lifecycle.r-lib.org/articles/stages.html#maturing"
  ],
  "review": {
    "@type": "Review",
    "url": "https://github.com/ropensci/software-review/issues/298",
    "provider": "https://ropensci.org"
  }
}

GitHub Events

Total
  • Watch event: 4
  • Issue comment event: 1
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Watch event: 4
  • Issue comment event: 1
  • Pull request event: 1
  • Fork event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 168
  • Total Committers: 9
  • Avg Commits per committer: 18.667
  • Development Distribution Score (DDS): 0.119
Past Year
  • Commits: 5
  • Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nicholas Potter p****t@g****m 148
Neal Richardson n****n@g****m 7
jsta s****2@m****u 5
Robert Dinterman r****n@g****m 2
Nicholas Potter 1****S 2
austinwpearce a****e@g****m 1
jpiaskowski j****k@g****m 1
Emrah Er e****r 1
Jonathan Adams j****6@g****m 1
Committer Domains (Top 20 + Academic)
msu.edu: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 30
  • Total pull requests: 10
  • Average time to close issues: 10 months
  • Average time to close pull requests: 15 days
  • Total issue authors: 13
  • Total pull request authors: 8
  • Average comments per issue: 2.23
  • Average comments per pull request: 1.4
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: about 5 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • potterzot (16)
  • sheilasaia (2)
  • wenlong-liu (2)
  • brandco (1)
  • PieceMaker (1)
  • maelle (1)
  • dwd62 (1)
  • jdeines (1)
  • danielreispereira (1)
  • rsmiller74 (1)
  • rdinter (1)
  • lindblb (1)
  • RafaRafa (1)
Pull Request Authors
  • austinwpearce (3)
  • potterzot (3)
  • PieceMaker (1)
  • jpiaskowski (1)
  • emraher (1)
  • nealrichardson (1)
  • jsta (1)
  • rdinter (1)
Top Labels
Issue Labels
enhancement (10) bug (1) help wanted (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
proxy.golang.org: github.com/ropensci/rnassqs
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • httr * imports
  • jsonlite * imports
  • stats * imports
  • utils * imports
  • here * suggests
  • httptest * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests