Skip to content

Commit

Permalink
Fixed parse_movs.cposg()
Browse files Browse the repository at this point in the history
  • Loading branch information
clente committed Aug 2, 2018
1 parent 808b7d7 commit 745ff71
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions R/parse_cposg.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ parse_movs.cposg <- function(parser) {

# Function for getting movements
get_movs <- function(html) {
html %>%
xml2::xml_find_all("//*[@id='tabelaTodasMovimentacoes']") %>%
xp0 <- "//*[@id='tabelaTodasMovimentacoes']"
tab <- xml2::xml_find_all(html, paste0(xp0, "//parent::table"))
tab %>%
rvest::html_table(fill = TRUE) %>%
purrr::pluck(1) %>%
janitor::clean_names() %>%
dplyr::as_tibble() %>%
dplyr::mutate(
X1 = lubridate::dmy(X1, quiet = TRUE),
X3 = str_replace_all(X3, "[\\t\\n]", ""),
X3 = str_replace_all(X3, "\\r", " "),
X3 = str_replace_all(X3, " +", " ")) %>%
dplyr::select(-X2) %>%
purrr::set_names("movement", "description")
dplyr::select(movement = data, X3 = movimento) %>%
dplyr::filter(movement != "") %>%
tidyr::separate(X3, c("title", "txt"), sep = "\n\t",
extra = "merge", fill = "right") %>%
dplyr::mutate_all(stringr::str_squish) %>%
dplyr::mutate(movement = lubridate::dmy(movement, quiet = TRUE))
}

# Add get_movs to getters
Expand Down

0 comments on commit 745ff71

Please sign in to comment.