nass_set_key {usdarnass} | R Documentation |
Set a Quick Stats API key
Description
This function will add your Quick Stats API key to your
.Renviron
file so it can be called securely without being stored in
your code. After you have installed your key, it can be called any time by
typing Sys.getenv("NASS_KEY")
and can be used in package functions
by simply typing NASS_KEY. If you do not have an .Renviron
file, the
function will create on for you. If you already have an .Renviron
file, the function will append the key to your existing file, while making
a backup of your original file for disaster recovery purposes.
Usage
nass_set_key(key = NULL, overwrite = FALSE)
Arguments
key |
The API key provided to you from NASS formatted in quotes. A key can be acquired at https://quickstats.nass.usda.gov/api |
overwrite |
If this is set to TRUE, it will write an existing
NASS_KEY that you already have in your |
Examples
## Not run:
set_nass_key("abcd012345678901234567890123456789")
# First time, relead your enviornment so you can use the key without
# restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("NASS_KEY")
## End(Not run)
## Not run:
# If you need to overwrite an existing key:
nass_set_key("abcd012345678901234567890123456789", overwrite = TRUE)
# First time, relead your enviornment so you can use the key without
# restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("NASS_KEY")
## End(Not run)