congressbr makes it easy to explore the API of the Brazilian Chamber of Deputies, or the Câmara dos Deputados. The package contains many functions that help researchers to download, standardise and tidy data from the Câmara website. This vignette shows some examples.

First, we need to install congressbr. You can install the package by running:

if(!require(devtools)){install.packages("devtools", repos = "http://cran.us.r-project.org")}
if(!require(ggplot2)){install.packages("ggplot2", repos = "http://cran.us.r-project.org")}
library(congressbr)
library(ggplot2)

Votes

congressbr has a dedicated function that returns a dataset with information about votes of a specific bill in the Câmara dos Deputados, the cham_votes() function. As we mentioned in the Senate vignette, the votes returned by the API are not necessarily nominal votes. This is because some votes are secret, thus the API only informs us if the deputy voted or not. Users have to provide the type (type =), number (number =) and year (year =) of the bill in question. Unfortunately, a particular bill can have more than one roll call, and the API does not provide an id to identify them. So we have provided one, the variable rollcall_id in the data frame. For instance, we can retrieve information about the proposition 1992/2007 with:

cham_votes(type = "PL", number = "1992", year = "2007")

The function returns many values that may be interesting to users, such as the summary of the decision (decision_summary), the guidelines given by the government and the opposition to the members of their respective coalitions (GOV_orientation and Minoria_orientation) and what political parties suggested to their deputies. In the example above, we could see how the PSDB (PSDB_orientation) and the PSOL (PSOL_orientation) orientated their members.

We can also get information about the legislator who proposed the bill, such as his or her name (legislator_name), the state that he or she represents (legislator_state), and his or her party affiliation (legislator_party). Those variables are available for each voting stage of the bill.

Bills

We have included two functions that retrieve details about particular bills. The first of them is cham_bill_info() function. This function requires three parameters, the bill's type (type =), number (number =) and year (year =). To retrieve the above-mentioned proposal (projeto de emenda constitucional), the PEC 472/1997, you can type:

cham_bill_info(type = "PEC", number = "472", year = "1997")

In another example, we can download data about the law proposition (projeto de lei) 3892/2008 with:

cham_bill_info(type = "PL", number = "3962", year = "2008")

The function return 19 variables, including the decision situation of the proposition (situation_desc), the full text in pdf (complete_link), and personal information about the author of the proposition (author_name, author_state, and author_party).

Another way of downloading the same information would be to use cham_bill_info_id(). The function requires the id of the bill. As an example, we can download some information about a proposal for constitutional amendment by Espiridião Amin, which has the id 14784, using the code below:

cham_bill_info_id(14784)

Users can download all every bill voted on in plenary in a given calendar year with cham_plenary_bills(). The function has a single parameter, year =, and returns the id of the bill (bill_id), its name (bill_name), and the day on which it was voted (vote_date)

cham_plenary_bills(year = 2008)

Finally, congressbr also features cham_typeauthors_bills(), a convenience function that downloads the types of authors for bills.

cham_typeauthors_bills()

Examples

In this brief example, we will examine how the parties orientated their deputies to vote in the law proposition 1992/2007, the same we have downloaded with the cham_votes() function. This example makes use of the ggplot2 package.

party_orientation <- cham_votes(type = "PL", number = "1992", year = "2007")
party_orientation <- as.data.frame(t(party_orientation[1, c(7, 10:22)])) # select only one row and the columns of interest; transpose data
names(party_orientation)[1] <- "orientation"

ggplot2::ggplot(party_orientation, aes(x = orientation)) +
  geom_bar(aes(fill = orientation), colour = "white") +
  theme_classic() + 
  scale_fill_hue(l = 40) + 
  ggtitle("Party Orientation - PL 1992/2007") +
  labs(x = "Orientation", y = "Count") + 
  theme(legend.position = "none")

Similarly, we could also have used the dplyr package to see how many parties suggested their members to vote "yay" (sim), "nay" (não), or allowed deputies to decide their votes (liberado).

if(!require(dplyr)){install.packages("dplyr", repos = "http://cran.us.r-project.org")}
library(dplyr)

party_orientation %>%
  group_by(orientation) %>%
  tally()

Similarly, we could also have used the dplyr package to see how many parties suggested their members to vote "yay" (sim), "nay" (não), or allowed deputies to decide their votes (liberado).

if(!require(dplyr)){install.packages("dplyr", repos = "http://cran.us.r-project.org")}
library(dplyr)

party_orientation %>%
  group_by(orientation) %>%
  tally()


RobertMyles/congressbr documentation built on July 18, 2020, 4:04 a.m.