Skip to contents

Retrieve data from Red Electrica Española.

Usage

ree_call(
  category,
  widget,
  start_date = end_date - 1,
  end_date = Sys.Date(),
  time_trunc = NULL,
  geo_trunc = NULL,
  region = "peninsular",
  lang = "es",
  parse = TRUE,
  ...
)

Arguments

category

Type of data, one of c("balance", "demanda", "generacion", "intercambios", "transporte").

widget

Defines what to retrieve.

start_date

Date

end_date

Date

time_trunc

One of c("hour", "day", "month", "year")

geo_trunc

Only accepts "electric_system".

region

One of c("peninsular", "canarias", "baleares", "ceuta", "melilla") or the official name of a CCAA (one of get_ree_ccaa()).

lang

Language: either "es" or "en".

parse

Decide if the function should try to parse the result or not (By default TRUE).

...

Other arguments passed to httr2::req_url_query().

Value

A data.frame by default or a list if parse = FALSE.

Examples

rc <- ree_call(start_date = as.Date("2018-01-01"),
               end_date = "2018-12-31T23:59",
               time_trunc = "month",
               region = "peninsular", lang = "en",
               category = "demanda", widget = "ire-general")
#> Last updated: 2022-03-23 00:00:00 
# rc2 <- ree_call(category = "balance", widget = "balance-electrico",
#                 start_date = "2022-12-31T23:59",
#                 region = "peninsular", lang = "en", time_trunc = "day")
# rc3 <- ree_call(lang = "es",
#                 category = "generacion",
#                 widget = "estructura-generacion",
#                 start_date = "2014-01-01T00:00",
#                 end_date = "2018-12-31T23:59",
#                 time_trunc = "year",
#                 geo_trunc = "electric_system",
#                 region = "Castilla la Mancha")