knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of finnishgrid is to provide an easy one-liner access to all Fingrid Open Data API functions.
You can install the development version of finnishgrid from GitHub with:
# install.packages("devtools") # required dependencies httr and jsonlite # install.packages(c("httr", "jsonlite")) devtools::install_github("virmar/finnishgrid")
Read basic API specification at https://data.fingrid.fi/en/pages/api.
Register free user account at https://data.fingrid.fi/open-data-forms/registration/.
Optional: add API key as your environment variable (~/.Renviron)
FINGRID_OPENDATA_API_KEY=MY_SECRET_KEY_FROM_EMAIL
Let's get Finnish hourly electricity consumption and production time-series data for basic visualization.
library(finnishgrid) start_time = "2021-01-01T00:00:00+0200" end_time = "2021-01-03T00:00:00+0200" user_key = NA # TODO: replace with right key or use .Renviron file
elec_cons <- electricity_consumption_FI_RTD(start_time = start_time, end_time = end_time, user_key = user_key) elec_prod <- electricity_production_FI_RTD(start_time = start_time, end_time = end_time, user_key = user_key) min_elec_cons <- min(elec_cons$value) # consumption max_elec_cons <- max(elec_cons$value) min_elec_prod <- min(elec_prod$value) # production max_elec_prod <- max(elec_prod$value) y_max <- max(max_elec_cons, max_elec_prod) y_min <- min(min_elec_cons, min_elec_prod)
plot(elec_cons$start_time, elec_cons$value, type = 'l', col = "green", ylim = c(y_min, y_max), ylab = "Produced/Consumed (MW)", xlab = "Time", main = "Electricity") lines(elec_prod$start_time, elec_prod$value, type = 'l', col = "blue") legend("topright", c("Cons", "Prod"), fill = c("green", "blue"))
API page: https://data.fingrid.fi/en/dataset/electricity-consumption-in-finland
tmp <- get_data(api_number = 124, # energy consumption start_time = start_time, end_time = end_time, user_key = NA) summary(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.