It was February 2018 when four people came together around open data:
rOpenSci is our form; Spanish public data, our matter
The github.com/rOpenSpain organization
The ropenspain.slack.com channel
Do you have a package about Spanish data?
Bring it to rOpenSpain!
Do you need help? Get an invite to our Slack!
siane_map()
.siane_merge()
.leaflet
}) provided by Spanish public organisms.terra
}) for static tiles.library(mapSpain)library(ggplot2)galicia <- esp_get_munic_siane(region = "Galicia") |> transform( Provincia = esp_dict_translate( ine.prov.name, "es" ) )ggplot(galicia) + geom_sf(aes(fill = Provincia), color = "grey70") + labs(title = "Provincias de Galicia") + scale_fill_discrete( type = hcl.colors(4, "Blues") ) + theme_bw()
terra
) for static tiles.library(CatastRo)library(ggplot2)burgo_osma <- catr_atom_get_buildings( "Burgo de Osma") |> sf::st_transform(4326)ggplot(burgo_osma) + geom_sf(aes(fill = currentUse), col = NA) + scale_fill_viridis_d(na.translate = FALSE) + theme_minimal() + coord_sf( xlim = c(-3.0752, -3.0679), ylim = c(41.5831, 41.5884) ) + labs( title = "El Burgo de Osma, Soria", fill = "Use of the building" )
library(CatastRoNav)library(ggplot2)olite <- c(-1.646812, 42.814528, -1.638036, 42.820320)olite_bu <- catrnav_wfs_get_buildings_bbox( olite, srs = 4326)ggplot(olite_bu) + geom_sf(aes(fill = value), color = NA) + scale_fill_viridis_b( show.limits = TRUE, breaks = seq(0, 30, 5) ) + theme_minimal() + labs( title = "Olite, Navarre", subtitle = "Height of buldings", fill = "meters" )
library(caRtociudad)soria <- cartociudad_geocode("ayuntamiento soria")soria_map <- cartociudad_get_map( c(soria$lat, soria$lng), 0.3)ggmap::ggmap(soria_map)
retrieve_sumario()
to retrieve summaries by date.library(BOE)library(ggplot2)sumario <- retrieve_sumario(as.Date("2022-05-06")) |> transform(dpt = sub("MINISTERIO", "M.", departament)) |> transform(dpt = stringr::str_trunc(dpt, 20))ggplot(sumario) + aes(forcats::fct_infreq(dpt)) + geom_bar() + coord_flip() + theme_minimal() + labs( title = "Publicaciones por departamento", subtitle = "BOE del 6 de mayo de 2022", caption = "Fuente: BOE", x = NULL )
library(infoelectoral)library(dplyr)library(ggplot2)df <- municipios("congreso", anno="1982", mes="10") |> group_by(siglas) |> summarise(votos = sum(votos)) |> mutate(seats = round(votos / sum(votos) * 350)) |> filter(seats >= 10)df <- ggparliament::parliament_data( df, type="semicircle", 7, df$seats)ggplot(df) + aes(x, y, colour = siglas) + ggparliament::geom_parliament_seats() + ggparliament::theme_ggparliament() + scale_color_manual(values=c( "#3399FF", "#3399FF", "#009900", "#0000EB", "#F10000", "#F10000", "#F10000", "#FFA500" )) + theme(legend.position = 'bottom')
library(senadoRES)library(dplyr)library(ggplot2)df <- senadores() |> group_by(legislatura) |> count(sex) |> filter(!is.na(sex)) |> mutate(ratio = n/sum(n)) |> filter(sex != "male")ggplot(df) + aes(legislatura, ratio) + geom_line() + geom_hline(yintercept=0.5, linetype=2, col="red") + scale_y_continuous( labels = scales::percent_format(accuracy = 1)) + theme_bw() + labs( title = "Ratio of women", x = "Legislatura", y = "% of women" )
publishers_available
).openes_load()
.openes_keywords()
.bde_ind_*
functions.ggplot2
}.2,000.32
with decimal comma is converted to 2000,32
).library(tidyBdE)library(ggplot2)euribor_month <- bde_ind_euribor_12m_monthly() |> subset(Date > "2010-01-01")ggplot(euribor_month) + aes(Date, Euribor_12M_Monthly) + geom_line(colour = bde_vivid_pal()(1)) + scale_y_continuous( labels = scales::number_format(suffix = "%") ) + theme_bde() + labs( title = "Euribor 12 months", subtitle = "Monthly data", caption = "Source: BdE" )
return_sf = TRUE
.aemet_api_key(..., install=TRUE)
.library(climaemet)library(ggplot2)temp2020 <- aemet_daily_period( "8416", start = 2020, end = 2020)ggplot(temp2020) + geom_col(aes(fecha, tmed, fill = tmed)) + scale_fill_gradientn( colours = hcl.colors(20, "RdBu", rev = TRUE), labels = scales::label_number(suffix = "º") ) + guides(fill = guide_colorsteps()) + theme_minimal() + labs( title = "Valencia, Spain", subtitle = "AEMET Station Id: 8416", fill = "Avg. daily temp.", y = "Celsius degrees", x = "date" )
library(dplyr)library(ggplot2)selection <- airqualityES::stations |> filter(station_name == "Barcelona (Sants)")df <- airqualityES::airqES |> filter(grepl(selection$id, station_id)) |> filter(pollutant == "PM10") |> mutate(pm10 = rowMeans( across(starts_with("D")), na.rm=TRUE)) |> mutate(date = as.Date(paste(year, month, 1, sep="-")))ggplot(df) + aes(date, pm10) + geom_line() + geom_smooth() + theme_bw() + labs( title = "Montly average of PM10", subtitle = "Measurement at Barcelona (Sants)" )
Much more could be done about the retrieval of statistical data
Mapping needs are pretty much covered, but improvements can always be made
opendataes needs your help!
Do you have other ideas? We'd love to hear you out!
Slides created via the R package xaringan with the rosxaringan template.
The chakra comes from remark.js, knitr, and R Markdown.
It was February 2018 when four people came together around open data:
rOpenSci is our form; Spanish public data, our matter
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |