Skip to content

Commit

Permalink
change sen_commissions_positions()
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertMyles committed May 8, 2019
1 parent 38ade9d commit 12c3aaf
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: congressbr
Type: Package
Title: Downloads, Unpacks and Tidies Legislative Data from the Brazilian Federal
Senate and Chamber of Deputies
Version: 0.2.0
Version: 0.2.1
Authors@R: c(
person(given = "Robert", family = "McDonnell", email = "mcdonnell.robert5@gmail.com", role = c("aut", "cre")),
person(given = "Guilherme", family = "Jardim Duarte", email = "gjardimduarte@gmail.com", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ importFrom(dplyr,as_data_frame)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_if)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# congressbr 0.2.1

- Small fixes to sen_commission_positions().

# congressbr 0.2.0

- Some functions have been removed from the package as they are presently unable from the API.
Expand Down
32 changes: 14 additions & 18 deletions R/sen_commission_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @importFrom magrittr '%>%'
#' @importFrom stringi stri_trans_general
#' @importFrom dplyr mutate
#' @importFrom dplyr filter
#' @importFrom purrr map
#' @importFrom purrr map_chr
#' @importFrom purrr flatten
Expand All @@ -27,41 +28,36 @@
#' @examples
#' jobs <- sen_commission_positions(active = "No")
#' @export
sen_commission_positions <- function(active = c("Yes", "No"),
sen_commission_positions <- function(active = c("Both", "Yes", "No"),
ascii = TRUE){


act <- match.arg(active)
if(act == "No") {
url <- "http://legis.senado.gov.br/dadosabertos/comissao/lista/tiposCargo?indAtivos=N"
} else{
url <- "http://legis.senado.gov.br/dadosabertos/comissao/lista/tiposCargo"
}
url <- "http://legis.senado.gov.br/dadosabertos/comissao/lista/tiposCargo"

req <- httr::GET(url)
req <- status(req)
req <- req$ListaTiposCargo$Cargos$Cargo
N <- NA_character_

jobs <- purrr::map_df(req, tibble::as_tibble) %>%
stats::setNames(c('comm_position_id', 'comm_position', 'comm_position_active'))
stats::setNames(c('commission_id', 'commission_position_description', 'active'))


if(isTRUE(ascii)){
jobs <- jobs %>%
dplyr::mutate(comm_position_active = ifelse(
comm_position_active == "S", "Yes", "No"
),
comm_position = stringi::stri_trans_general(
comm_position, "Latin-ASCII"
dplyr::mutate(active = ifelse(active == "S", "Yes", "No"),
commission_position_description = stringi::stri_trans_general(
commission_position_description, "Latin-ASCII"
))
return(jobs)
} else{
jobs <- jobs %>%
dplyr::mutate(comm_position_active = ifelse(
comm_position_active == "S", "Yes", "No"
))
return(jobs)
dplyr::mutate(active = ifelse(active == "S", "Yes", "No"))
}

if(act == "No") jobs <- dplyr::filter(jobs, active == "No")
if(act == "Yes") jobs <- dplyr::filter(jobs, active == "Yes")

return(jobs)
}


Expand Down
2 changes: 1 addition & 1 deletion R/sen_votes.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' set of votes for each legislature, see \code{data("senate_nominal_votes")}.
#' @examples
#' \dontrun{
#' en_votes(date = "20130516")
#' sen_votes(date = "20130516")
#'
#' # Some votes are secret:
#' ssshhh <- sen_votes("20160301", binary = FALSE)
Expand Down
4 changes: 2 additions & 2 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NULL
# response status check
status <- function(x){
if(x$status_code != 200){
stop("GET request failed. Please check the validity of the information you requested.")
stop("Request failed. Please check the validity of the information you requested.")
} else{
xx <- httr::content(x, as = "parsed")

Expand Down Expand Up @@ -99,5 +99,5 @@ if(getRversion() >= "2.15.1") utils::globalVariables(
"absence_description", "sen_bills_list", 'type', 'number', 'year',
'initial_date', 'end_date', 'part_name_author', 'id_type_author',
'abbreviation_party_author', 'abbreviation_st_author', 'legislator_vote',
"bill_details", "legislator_party"))
"bill_details", "legislator_party", "commission_position_description"))

4 changes: 4 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.2.1

- Small fixes to sen_commission_positions()

## Version 0.2.0

- Removed functions which had been taken out of the API without notice.
Expand Down
2 changes: 1 addition & 1 deletion man/sen_commission_positions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/sen_votes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12c3aaf

Please sign in to comment.