-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
89 lines (68 loc) · 2.62 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
85
86
87
88
89
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- 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%"
)
```
# senadoRES
<!-- badges: start -->
[![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)
<!-- badges: end -->
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`.