nass_set_key: Set a Quick Stats API key

Description Usage Arguments Examples

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

1
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 .Renviron file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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)

usdarnass documentation built on June 21, 2019, 9:06 a.m.