Package 'resios'

Title: Interacts with REE and ESIOS API
Description: Provides functions to retrieve and use easily data from Red Electrica Española (REE) the which operates the national electricity grid in Spain. The REE also provides ESIOS from electronic-"Sistema de Información del Operador del Sistema", which is also covered here.
Authors: Lluís Revilla Sancho [aut, cre]
Maintainer: Lluís Revilla Sancho <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9003
Built: 2024-09-16 00:53:31 UTC
Source: https://github.com/rOpenSpain/resios

Help Index


Retrieve archives from ESIOS

Description

Check which archives are available.

Usage

esios_archives()

Value

A data.frame with the information of what is available and where.

Examples

archives <- esios_archives()
head(archives)

Retrieve an indicator

Description

Retrieve the information of any indicator based on the id.

Usage

esios_indicators(
  indicator,
  locale = NULL,
  datetime = NULL,
  start_date = NULL,
  end_date = NULL,
  time_agg = NULL,
  time_trunc = NULL,
  geo_agg = NULL,
  geo_ids = NULL,
  geo_trunc = NULL
)

Arguments

indicator

ID code for an indicator

locale

Get translations for sources (es, en). Default language: es

datetime

A certain date to filter values by (iso8601 format)

start_date

Beginning of the date range to filter indicator values (iso8601 format)

end_date

End of the date range to filter indicator values (iso8601 format)

time_agg

How to aggregate indicator values when grouping them by time. Accepted values: 'sum', 'average'. Default value: 'sum'.

time_trunc

Tells the API how to trunc data time series. Accepted values: 'five_minutes', 'ten_minutes', 'fifteen_minutes', 'hour', 'day', 'month', 'year'.

geo_agg

How to aggregate indicator values when grouping them by geo_id. Accepted values: 'sum', 'average'. Default value: 'sum'.

geo_ids

Tells the API the geo ids to filter the date.

geo_trunc

Tells the API how to group data at geolocalization level when the geo_agg is informed. Accepted values: 'country', 'electric_system', 'autonomous_community', 'province', 'electric_subsystem', 'town' and 'drainage_basin'.

References

https://api.esios.ree.es/

See Also

esios_search_indicators()

Examples

ei10001 <- esios_indicators(10001)
head(ei10001)

Prediction of electricity prices using indicator 1001

Description

This is a shortcut for esios_indicators("1001") with some parsing.

Usage

esios_pvpc(
  locale = NULL,
  datetime = NULL,
  start_date = NULL,
  end_date = NULL,
  time_agg = NULL,
  time_trunc = NULL,
  geo_agg = NULL,
  geo_ids = NULL,
  geo_trunc = NULL
)

Arguments

locale

Get translations for sources (es, en). Default language: es

datetime

A certain date to filter values by (iso8601 format)

start_date

Beginning of the date range to filter indicator values (iso8601 format)

end_date

End of the date range to filter indicator values (iso8601 format)

time_agg

How to aggregate indicator values when grouping them by time. Accepted values: 'sum', 'average'. Default value: 'sum'.

time_trunc

Tells the API how to trunc data time series. Accepted values: 'five_minutes', 'ten_minutes', 'fifteen_minutes', 'hour', 'day', 'month', 'year'.

geo_agg

How to aggregate indicator values when grouping them by geo_id. Accepted values: 'sum', 'average'. Default value: 'sum'.

geo_ids

Tells the API the geo ids to filter the date.

geo_trunc

Tells the API how to group data at geolocalization level when the geo_agg is informed. Accepted values: 'country', 'electric_system', 'autonomous_community', 'province', 'electric_subsystem', 'town' and 'drainage_basin'.

Value

A data.frame with value ( €/MWh), datetime, datetime_utc, tz_time, geo_id and geo_name.

See Also

esios_indicators()

Examples

e <- esios_pvpc()

List ESIOS indicators

Description

Find which indicators are available.

Usage

esios_search_indicators(
  text = NULL,
  taxonomy_terms = NULL,
  taxonomy_ids = NULL
)

Arguments

text

Text to search indicators

taxonomy_terms

Terms of indicators

taxonomy_ids

Ids of the indicators

Value

A data.frame with four columns: name, description, short_name and id.

See Also

esios_indicators()

Examples

ei <- esios_search_indicators()
mercados <- esios_search_indicators(text = "Mercados y precios")

Get all the CCAA available

Description

Get all the CCAA available

Usage

get_ree_ccaa()

Value

A vector with the regions

See Also

ree_call()

Examples

get_ree_ccaa()

Get ESIOS token

Description

To get a token you need to ask for it.

Usage

get_token(token = NULL)

Arguments

token

The character string as a token

Value

Invisible the token

Examples

token <- get_token("aahdahgagdadfsafd")

Retrieve data from Red Electrica Española.

Description

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")
# 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")