Exploring the Brazilian Federal Senate

Robert McDonnell, Guilherme Duarte and Danilo Freire

2018-05-15

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:

install.packages("congressbr")

And then loaded with:

library(congressbr)

Votes

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.

sen_votes(date = "20160908")
## # A tibble: 486 x 16
##    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 10 more variables: bill_year <chr>,
## #   bill_description <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:

sen_plenary_result(date = "20160303")
## # 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  "REQU… RQS       00116       2016      3719       21            
## 2 125012  "REQU… RQS       00127       2016      3719       21            
## 3 123432  PROJE… MPV       00693       2015      3719       21            
## 4 123467  "PROJ… MPV       00696       2015      3719       21            
## 5 122838  "PROJ… PLS       00555       2015      3719       21            
## 6 83503   "PROJ… PRS       00084       2007      3719       21            
## 7 124453  "PROJ… PRS       00061       2015      3719       21            
## 8 122690  "PROP… PEC       00110       2015      3719       21            
## 9 124879  "PROJ… 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>

Senator info

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(). Information on the commissions that the senator has served on is available with sen_senator_commissions(), and the bills that they sponsored or authored with sen_senator_bills(). 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():

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 Marc… Acir Gurgacz  Mascul… http://w… http://w… acir@senado…
##  2 5140  Airton Sa… Airton Sando… Mascul… http://w… http://w… sen.airtons…
##  3 945   Alvaro Fe… Alvaro Dias   Mascul… http://w… http://w… alvarodias@…
##  4 4988  Ana Ameli… Ana Amelia    Femini… http://w… http://w… ana.amelia@…
##  5 5529  Antonio A… Antonio Anas… Mascul… http://w… http://w… antonio.ana…
##  6 3     Antonio C… Antonio Carl… Mascul… http://w… http://w… antoniocarl…
##  7 715   Armando d… Armando Mont… Mascul… http://w… http://w… armando.mon…
##  8 5164  Ataides d… Ataides Oliv… Mascul… http://w… http://w… ataides.oli…
##  9 391   Aecio Nev… Aecio Neves   Mascul… http://w… http://w… aecio.neves…
## 10 3823  Benedito … Benedito de … Mascul… http://w… http://w… benedito.li…
## # ... 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>
sen_senator_details(id = "3398") # Cristovam Buarque
## # A tibble: 1 x 16
##   senator_id senator_name      senator_party_name        senator_party_ab…
##   <chr>      <chr>             <chr>                     <chr>            
## 1 3398       Cristovam Buarque Partido Popular Socialis… PPS              
## # ... with 12 more variables: senator_party_date_joined <dttm>,
## #   senator_state <chr>, senator_status <chr>, senator_gender <chr>,
## #   senator_date_of_birth <dttm>, senator_state_of_birth <chr>,
## #   senator_title <chr>, senator_mandates_first_legis <chr>,
## #   senator_mandates_second_legis <chr>, senator_url <chr>,
## #   senator_email <chr>, senator_office_address <chr>
sen_senator_bills(id = "3398")
## # A tibble: 107 x 9
##    senator_id senator_name senator_party_n… senator_party_a… senator_state
##    <chr>      <chr>        <chr>            <chr>            <chr>        
##  1 3398       Cristovam B… Partido Popular… PPS              DF           
##  2 3398       Cristovam B… Partido Popular… PPS              DF           
##  3 3398       Cristovam B… Partido Popular… PPS              DF           
##  4 3398       Cristovam B… Partido Popular… PPS              DF           
##  5 3398       Cristovam B… Partido Popular… PPS              DF           
##  6 3398       Cristovam B… Partido Popular… PPS              DF           
##  7 3398       Cristovam B… Partido Popular… PPS              DF           
##  8 3398       Cristovam B… Partido Popular… PPS              DF           
##  9 3398       Cristovam B… Partido Popular… PPS              DF           
## 10 3398       Cristovam B… Partido Popular… PPS              DF           
## # ... with 97 more rows, and 4 more variables: senator_bills_number <chr>,
## #   senator_bills_type <chr>, senator_bills_year <chr>,
## #   senator_bills_details <chr>

Commissions and coalitions

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(). Further information on the coalition of interest can be had with sen_coalition_info(). For example, the Bloco Moderador (moderate bloc) has the id 200. We can obtain more detailed information on the coalition by using this id with the code option:

sen_coalition_info(code = 200)
## # A tibble: 5 x 11
##   bloc_code house bloc_name  bloc_label   date_created        coalition_id
##   <chr>     <chr> <chr>      <chr>        <dttm>              <chr>       
## 1 200       Bloco Bloco Mod… Bloco PTB, … 2015-02-01 00:00:00 389         
## 2 200       Bloco Bloco Mod… Bloco PTB, … 2015-02-01 00:00:00 390         
## 3 200       Bloco Bloco Mod… Bloco PTB, … 2015-02-01 00:00:00 392         
## 4 200       Bloco Bloco Mod… Bloco PTB, … 2015-02-01 00:00:00 391         
## 5 200       Bloco Bloco Mod… Bloco PTB, … 2015-02-01 00:00:00 497         
## # ... with 5 more variables: member_code <chr>, member_data_joined <dttm>,
## #   member_abbr <chr>, member_name <chr>, member_date_created <dttm>

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”:

data("commissions")
sen_commissions_senators(code = "CCJ")
## # A tibble: 0 x 6
## # ... with 6 variables: commission <chr>, commission_abbr <chr>,
## #   senator_id <chr>, senator_name <chr>, senator_party <chr>,
## #   senator_state <chr>

General Information

Parties

A list of the parties who have held seats in the Senate can be had with sen_parties():

## # A tibble: 47 x 4
##    party_id party_abbr party_name                       date_created
##    <chr>    <chr>      <chr>                            <chr>       
##  1 578      AVANTE     AVANTE                           2017-09-12  
##  2 554      DEM        Democratas                       2007-03-28  
##  3 566      NOVO       Partido Novo                     2015-09-15  
##  4 142      PAN        Partido dos Aposentados da Nacao 1998-02-19  
##  5 94       PCB        Partido Comunista Brasileiro     1922-03-25  
##  6 144      PCN        Partido Comunitario  Nacional    1985-07-01  
##  7 145      PCO        Partido da Causa Operaria        1997-09-30  
##  8 86       PCdoB      Partido Comunista do Brasil      1962-02-01  
##  9 20       PDT        Partido Democratico Trabalhista  1980-09-16  
## 10 559      PEN        Partido Ecologico Nacional       2012-06-19  
## # ... with 37 more rows

States

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"

Bill types

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, 1… Reuniao de T… Reuniao     2016-11-07 00:00:00
##  2 5537      CDH, as 10h, 9… Audiencia Pu… Extraordin… 2016-11-07 00:00:00
##  3 5553      CCS, as 14h, 1… Reuniao de T… Reuniao     2016-11-07 00:00:00
##  4 5576      CJD, as 14h:30… Audiencia Pu… Reuniao     2016-11-07 00:00:00
##  5 5591      CDH, as 15h, 9… Audiencia Pu… Extraordin… 2016-11-07 00:00:00
##  6 5563      CCT, as 08h:45… Audiencia Pu… Extraordin… 2016-11-08 00:00:00
##  7 5535      CDH, as 09h, 9… Audiencia Pu… Extraordin… 2016-11-08 00:00:00
##  8 5578      CMA, as 09h:30… Deliberativa  Extraordin… 2016-11-08 00:00:00
##  9 5598      CCJ,CAE, as 10… Audiencia Pu… Conjunta    2016-11-08 00:00:00
## 10 5581      CTG, as 11h, 1… <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>

Examples

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.)

Looking at the distribution of Titular senators and deputies (suplentes) is also straightforward:

Which states have the most suplentes?

## # A tibble: 12 x 2
##    state totals
##    <chr>  <int>
##  1 MT         2
##  2 BA         1
##  3 DF         1
##  4 GO         1
##  5 MG         1
##  6 MS         1
##  7 PB         1
##  8 PI         1
##  9 RJ         1
## 10 SC         1
## 11 SP         1
## 12 TO         1

Mato Grosso, it seems, with two-thirds of their senators being stand-in suplentes.