An open API service indexing awesome lists of open source software.

https://github.com/ropenspain/senadores

Information about the senators of Spain.
https://github.com/ropenspain/senadores

goverment-data rstats-package spain transparency

Last synced: about 2 months ago
JSON representation

Information about the senators of Spain.

Awesome Lists containing this project

README

          

---
output: github_document
editor_options:
chunk_output_type: console
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# senadoRES

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Codecov test coverage](https://codecov.io/gh/rOpenSpain/senadoRES/branch/master/graph/badge.svg)](https://codecov.io/gh/rOpenSpain/senadoRES?branch=master)
[![R-CMD-check](https://github.com/rOpenSpain/senadoRES/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rOpenSpain/senadoRES/actions/workflows/R-CMD-check.yaml)

The goal of senadoRES is to provide information about the [Senate of Spain](https://en.wikipedia.org/wiki/Senate_of_Spain).
It uses the [Open Data](https://www.senado.es/web/relacionesciudadanos/datosabiertos/catalogodatos/index.html) available and some other XML files I found while exploring the website.

## Installation

You can install the released version of senadoRES with:

``` r
remotes::install_github("llrs/senadoRES")
```

## Example

To make it easier to work and show some data I'll use some packages:

```{r example}
library("senadoRES")
library("dplyr")
library("ggplot2")
```

### Senadores

This function return the members of the Senate:

```{r senadores}
ts <- senadores()
head(ts)
```

We can see the increase of females on the Senate along the legislatures:

```{r senadoras}
ts %>%
group_by(legislatura) %>%
count(sex) %>%
mutate(total = sum(n)) %>%
filter(!is.na(sex)) %>%
mutate(ratio = n/total) %>%
filter(sex != "male") %>%
ggplot() +
geom_point(aes(legislatura, ratio), size = 5) +
geom_hline(yintercept = 0.5, linetype = 2, col = "red") +
scale_x_continuous(breaks = seq_len(15)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1),
breaks = seq(from = 0, to = 1, by = .1),
expand = expansion(add = c(0.01, 0.01)), limits = c(0, NA)) +
theme_minimal() +
labs(title = "Ratio of women", x = "Legislatura", y = "% of women") +
guides(col = "none", shape = "none") +
theme(panel.grid.minor.x = element_blank())
```

Or see what has been done:

```{r boletin}
b <- boletin(boletin_csv(14, 1))
b[, c("FECHA", "DISP", "apartado", "subapartado", "TITULO", "document")]
```

So, on the first session of the 14th legislature they dealt with human resources.
We can check one of those documents, to retrieve the text with `documento`.