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

senadoRES

Lifecycle: experimental Codecov test coverage R-CMD-check

The goal of senadoRES is to provide information about the Senate of Spain. It uses the Open Data available and some other XML files I found while exploring the website.

Installation

You can install the released version of senadoRES with:

remotes::install_github("llrs/senadoRES")

Example

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

library("senadoRES")
library("dplyr")
library("ggplot2")

Senadores

This function return the members of the Senate:

ts <- senadores()
head(ts)

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

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:

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.



rOpenSpain/senadoRES documentation built on Dec. 26, 2024, 8:18 p.m.