The API of the Brazilian Federal Senate can be explored with congressbr
by searching for details on individual senators, commissions and votes, among other options.
congressbr
can be installed by running:
And then loaded with:
The voting behaviour of legislators is an area of great interest both inside and outside of academia. congressbr
has the sen_votes()
function, which returns a data frame of votes in the Senate. These are not necessarily nominal votes, as some may be secret votes. In this case, the API records whether the senator voted or not. The other variables in the data frame returned pertain to the time of the vote, its number, id, year, description and its result. Information on individual senators (their party, name, id, gender and state) is also returned. This function has an argument, binary
, which if TRUE
, transforms the recorded (nominal) votes from “Yes” to 1 and “No” to 0. This is handy if you want to use the wnominate, pscl or MCMCpack functions to run ideal point analyses, for example. Please note that dates are in “yyyymmdd
” format.
## # A tibble: 486 x 17
## vote_date vote_time vote_round bill_id bill_number bill_type
## <dttm> <chr> <dbl> <chr> <chr> <chr>
## 1 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 2 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 3 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 4 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 5 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 6 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 7 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 8 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 9 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## 10 2016-09-08 00:00:00 14:00 1 126544 00076 MSF
## # … with 476 more rows, and 11 more variables: bill_year <chr>,
## # bill_description <chr>, rollcall_id <chr>, vote_result <chr>,
## # vote_secret <chr>, senator_id <chr>, senator_name <chr>,
## # senator_vote <chr>, senator_gender <chr>, senator_party <chr>,
## # senator_state <chr>
For convenience, we have included a dataset of all nominal votes in the Federal Senate from 1991 to early 2017, which can be accessed with data("sen_nominal_votes")
. The dataset is only 38KB and can be loaded quickly on any computer.
If you want to know more about the results from the plenary in the Federal Senate for a specified date, you may also use the sen_plenary()
function. As an example, you can retrieve information from the session of the 3rd of March 2016 with:
## # A tibble: 9 x 17
## bill_id bill bill_type bill_number bill_year session_id session_number
## <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 124978 "REQ… RQS 00116 2016 3719 21
## 2 125012 "REQ… RQS 00127 2016 3719 21
## 3 123432 PROJ… MPV 00693 2015 3719 21
## 4 123467 "PRO… MPV 00696 2015 3719 21
## 5 122838 "PRO… PLS 00555 2015 3719 21
## 6 83503 "PRO… PRS 00084 2007 3719 21
## 7 124453 "PRO… PRS 00061 2015 3719 21
## 8 122690 "PRO… PEC 00110 2015 3719 21
## 9 124879 "PRO… PDS 00006 2016 3719 21
## # … with 10 more variables: session_date <dttm>, session_time <chr>,
## # session_type <chr>, session_type_abbr <chr>, session_house <chr>,
## # bill_house <chr>, bill_report <chr>, bill_details <chr>,
## # bill_result <chr>, bill_sponsor <chr>
Information on individual senators can be had with sen_senator_details()
. This function returns the senator’s id, name, party and state, as well as information on his/her date of birth, place of birth, their mandates, and office information such as email and correspondence address. If the senator is a titular senator, information on his/her deputies (suplentes) is available with sen_senator_suplentes()
. The senator’s votes can be had with sen_senator_votes()
, and their mandates with sen_senator_mandates()
. For information on absences and party affiliations, use sen_senator()
. All of these functions use the senator’s id (with the id
option). A data frame of all of these is available from the function sen_senator_list()
:
## # A tibble: 81 x 17
## id name_full name_senator gender foto_url page_url office_email
## <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 4981 Acir Mar… Acir Gurgacz Mascu… http://… http://… acir@senado…
## 2 5982 Alessand… Alessandro … Mascu… http://… http://… sen.alessan…
## 3 945 Alvaro F… Alvaro Dias Mascu… http://… http://… alvarodias@…
## 4 5967 Angelo M… Angelo Coro… Mascu… http://… http://… sen.angeloc…
## 5 5529 Antonio … Antonio Ana… Mascu… http://… http://… antonio.ana…
## 6 751 Arolde d… Arolde de O… Mascu… http://… http://… sen.arolded…
## 7 5990 Carlos A… Carlos Viana Mascu… http://… http://… sen.carlosv…
## 8 470 Francisc… Chico Rodri… Mascu… http://… http://… sen.chicoro…
## 9 5973 Cid Ferr… Cid Gomes Mascu… http://… http://… sen.cidgome…
## 10 739 Ciro Nog… Ciro Noguei… Mascu… http://… http://… ciro.noguei…
## # … with 71 more rows, and 10 more variables: party_abbr <chr>,
## # id_mandate <chr>, state <chr>, status <chr>,
## # num_legislature_first_term <chr>, first_term_start <dttm>,
## # first_term_end <dttm>, num_legislature_second_term <chr>,
## # second_term_start <dttm>, second_term_end <dttm>
There are certain legislative coalitions in the Senate, all of whom have unique id numbers in the API database. These numbers can be accessed with sen_coalitions()
.
A data frame of commissions (full name and abbreviation) can be obtained with data("commissions")
. The sen_commissions()
function returns a detailed dataframe of commissions, their ids, type, house and purpose. Commissions can be explored by type
variable returned from this function. For example, the “cpi” type (Comissão de Inquérito Parlamentar, Parliamentary Inquiry Commission) can be used in the sen_commissions_type()
function, which will return a data frame of commissions of the type specified.
Using the commission abbreviations, we can see which senators serve on the commission. One well-known commission is the Commission for the Constitution, Justice and Citizenship (Constituicao, Justica e Cidadania). Its abbreviation is “CCJ”:
## # A tibble: 17 x 6
## commission commission_abbr senator_id senator_name senator_party
## <chr> <chr> <chr> <chr> <chr>
## 1 Comissao … CCJ 4994 Eduardo Bra… MDB
## 2 Comissao … CCJ 3361 Jose Maranh… MDB
## 3 Comissao … CCJ 1173 Wellington … PR
## 4 Comissao … CCJ 5529 Antonio Ana… PSDB
## 5 Comissao … CCJ 677 Roberto Roc… PSDB
## 6 Comissao … CCJ 5008 Humberto Co… PT
## 7 Comissao … CCJ 90 Jose Serra PSDB
## 8 Comissao … CCJ 5012 Randolfe Ro… REDE
## 9 Comissao … CCJ 5929 Selma Arruda PSL
## 10 Comissao … CCJ 5533 Lasier Mart… PODE
## 11 Comissao … CCJ 2331 Rose de Fre… PODE
## 12 Comissao … CCJ 1023 Maria do Ca… DEM
## 13 Comissao … CCJ 739 Ciro Noguei… PP
## 14 Comissao … CCJ 742 Marcelo Cas… MDB
## 15 Comissao … CCJ 5527 Simone Tebet MDB
## 16 Comissao … CCJ 581 Jaques Wagn… PT
## 17 Comissao … CCJ 4560 Sergio Pete… PSD
## # … with 1 more variable: senator_state <chr>
A list of the parties who have held seats in the Senate can be had with sen_parties()
:
## # A tibble: 49 x 4
## party_id party_abbr party_name date_created
## <chr> <chr> <chr> <chr>
## 1 578 AVANTE AVANTE 2017-09-12
## 2 581 DC Democracia Crista 2015-01-01
## 3 554 DEM Democratas 2007-03-28
## 4 33 MDB Movimento Democratico Brasileiro 1980-01-01
## 5 566 NOVO Partido Novo 2015-09-15
## 6 142 PAN Partido dos Aposentados da Nacao 1998-02-19
## 7 579 PATRI Patriota 2018-04-26
## 8 94 PCB Partido Comunista Brasileiro 1922-03-25
## 9 144 PCN Partido Comunitario Nacional 1985-07-01
## 10 145 PCO Partido da Causa Operaria 1997-09-30
## # … with 39 more rows
For some functions, there are options to narrow the search by focusing on certain states. If you are not familiar with all of the Brazilian states or with their commonly-used abbreviations, use the UF()
function to print out a list of these abbreviations. For the full names of the states and their abbreviations, use data("statesBR")
.
## [1] "AC" "AL" "AP" "AM" "BA" "CE" "DF" "ES" "GO" "MA" "MT" "MS" "MG" "PA"
## [15] "PB" "PR" "PE" "PI" "RJ" "RN" "RS" "RO" "RR" "SC" "SP" "SE" "TO"
The Senate API can be queried by the type of bill. If you are not familiar with the types of bills that come to the Senate floor, use sen_bills_types()
. Other similar functions, useful for getting to know the Senate, are sen_plenary_sessions()
, which returns data on the types of sessions held in the Senate, sen_bills_topics()
, which returns a data frame with the topic labels for different subject categories.
The bill types can be used for other queries, such as for seeing what bills of a certain type are currently passing through the house. For example, we can see which MPVs (medida provisória; executive decree) were under consideration in the Senate in 2001:
## # A tibble: 49 x 4
## bill_id bill_number bill_year bill_type
## <chr> <chr> <chr> <chr>
## 1 48017 02162 2001 MPV
## 2 48018 02163 2001 MPV
## 3 48019 02167 2001 MPV
## 4 48020 02170 2001 MPV
## 5 48021 02172 2001 MPV
## 6 48022 02173 2001 MPV
## 7 48025 02189 2001 MPV
## 8 48032 02161 2001 MPV
## 9 48034 02165 2001 MPV
## 10 48036 02190 2001 MPV
## # … with 39 more rows
This function can also be used to get information for a single date.
congressbr
also has functions for accessing budget information (sen_budget()
), and the agenda in the Senate for a particular date, or range of dates:
## # A tibble: 87 x 12
## agenda_id agenda_title agenda_name agenda_type agenda_date
## <chr> <chr> <chr> <chr> <dttm>
## 1 5551 CCS, as 09h… Reuniao de… Reuniao 2016-11-07 00:00:00
## 2 5537 CDH, as 10h… Audiencia … Extraordin… 2016-11-07 00:00:00
## 3 5553 CCS, as 14h… Reuniao de… Reuniao 2016-11-07 00:00:00
## 4 5576 CJD, as 14h… Audiencia … Reuniao 2016-11-07 00:00:00
## 5 5591 CDH, as 15h… Audiencia … Extraordin… 2016-11-07 00:00:00
## 6 5563 CCT, as 08h… Audiencia … Extraordin… 2016-11-08 00:00:00
## 7 5535 CDH, as 09h… Audiencia … Extraordin… 2016-11-08 00:00:00
## 8 5578 CMA, as 09h… Deliberati… Extraordin… 2016-11-08 00:00:00
## 9 5598 CCJ,CAE, as… Audiencia … Conjunta 2016-11-08 00:00:00
## 10 5581 CTG, as 11h… <NA> Extraordin… 2016-11-08 00:00:00
## # … with 77 more rows, and 7 more variables: agenda_time <chr>,
## # agenda_status <chr>, agenda_place <chr>,
## # agenda_commission_house <chr>, agenda_commission_abbr <chr>,
## # agenda_commission_id <chr>, agenda_commission_meeting_number <chr>
congressbr
can be used for various types of analyses. As a quick example, let’s explore the distribution of men and women currently sitting in the house. (This example makes use of the ggplot2 package.)
library(ggplot2)
all_sens <- sen_senator_list()
ggplot(all_sens, aes(x = gender)) +
geom_bar(aes(fill = gender), colour = "white") +
theme_classic() +
scale_fill_manual(values = c("#45C74A", "#FFFF00"))
Looking at the distribution of Titular senators and deputies (suplentes) is also straightforward:
theme_classic() +
scale_fill_manual(values = c("#45C74A", "navy")) +
theme(legend.position = "none") +
coord_flip()
Which states have the most suplentes?
if(!require(dplyr)){install.packages("dplyr", repos = "http://cran.us.r-project.org")}
library(dplyr)
all_sens %>% filter(status != "Titular") %>% group_by(state) %>%
summarise(totals = n()) %>% arrange(desc(totals))
## # A tibble: 3 x 2
## state totals
## <chr> <int>
## 1 AC 1
## 2 GO 1
## 3 RN 1
Mato Grosso, it seems, with two-thirds of their senators being stand-in suplentes.