-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
85 lines (62 loc) · 2.39 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# resios
<!-- badges: start -->
[![R-CMD-check](https://github.com/llrs/resios/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/llrs/resios/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of resios is to provide an easy way to interact with the ESIOS API.
## Installation
You can install the development version of resios from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("llrs/resios")
```
# Status
This packages includes the minimal functions to make it usable for me.
If anyone want to query some other data and the parser do not work well, open an issue and I'll try to fix it.
## Examples
We need to load the library and prepare the token for the session.
See the `get_token()` help page for information about how to do that.
```{r load}
library("resios")
get_token()
```
Once ready we can look for some indicators (also to check that our token works):
```{r search_indicators}
ei <- esios_search_indicators()
head(ei)
```
There are many indicators (`r NROW(ei)`) and as you can see some are updated quite frequently daily.
Others the date is unclear and you should read the last sentence of the description.
The one probably more interesting is the price of electricity in the state contract (updated each day at 20:20).
There is a direct function for that one:
```{r pvpc}
ei[ei$id == "1001", -2]
head(esios_pvpc())
```
You can filter and plot it.
## REE
You can also query the Red Eléctrica Española directly (it doesn't require to get a token):
```{r ree}
rc0 <- ree_call(widget = "demanda-tiempo-real", category = "demanda")
plot(rc0$`Demanda real`$datetime, rc0$`Demanda real`$value, type = "l", pch = 2,
main = "Electricity demand in peninsular Spain",
xlab = "Time", ylab = "Value (?)")
lines(rc0$`Demanda programada`$datetime, rc0$`Demanda programada`$value,
type = "l", col = "blue", lty = 2)
lines(rc0$`Demanda prevista`$datetime, rc0$`Demanda prevista`$value,
type = "l", col = "red", lty = 3)
abline(h = Sys.time(), col = "black")
legend("topleft", legend = c("real", "foreseen", "programmed"),
fill = c("black", "red", "blue"))
```