eia_data | R Documentation |
Obtain data from the EIA.
eia_data(
dir,
data = NULL,
facets = NULL,
freq = NULL,
start = NULL,
end = NULL,
sort = NULL,
length = NULL,
offset = NULL,
tidy = TRUE,
check_metadata = FALSE,
cache = TRUE,
key = eia_get_key()
)
dir |
character, directory path. |
data |
character or
|
facets |
character list or |
freq |
character or |
start , end |
character or |
sort |
named list of two.
|
length |
numeric or |
offset |
numeric or |
tidy |
logical or |
check_metadata |
logical, if |
cache |
logical, cache result for duration of R session using memoization. See details. |
key |
API key: character if set explicitly; not needed if key is set
globally. See |
By default, data
, facets
, and freq
are set to NULL
. To obtain valid
input values for each of these arguments, use the specific ID labels
as provided by eia_metadata()
.
The use of start
and end
require some input to freq
.
By default (check_metadata = FALSE
), the resulting data will match the
temporal resolution provided to freq
, however, check_metadata = TRUE
applies
further restrictions such that the format of values provided to start
/end
must match
that of freq
. Furthermore, regardless of the input format provided to start
/end
,
the resulting data will always match the specification of freq
. And lastly,
regardless of chosen format, end
must be strictly greater than start
to return data.
By default, additional processing is done to return a list containing tibble data frames.
Set tidy = FALSE
to return only the initial list result of jsonlite::fromJSON
.
Set tidy = NA
to return the original JSON as a character string.
Set to cache = FALSE
to force a new API call for updated data.
Using FALSE
always makes a new API call and returns the result from the server.
TRUE
uses memoization on a per R session basis, caching the result of the
function call in memory for the duration of the R session.
You can reset the entire cache by calling eia_clear_cache()
.
data frame
## Not run:
eia_data(
dir = "electricity/retail-sales",
data = "price",
facets = list(sectorid = c("COM", "RES"), stateid = "OH")
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.