R/tjsp_obter_valor_max.R

Defines functions tjsp_obter_valor_max

Documented in tjsp_obter_valor_max

#' Obtêm valor máximo do julgado
#'
#' @param julgado Julgado ou trecho do julgao de interesse
#'
#' @return Valor
#' @export
#'
tjsp_obter_valor_max <- function(julgado){
  julgado |>
    stringr::str_extract_all("R\\$[\\s.]?\\d\\S+") |>
    purrr::map_dbl(~{
      .x |>
        stringr::str_extract(".+?(?=\\D?$)") |>
        stringr::str_remove_all("(\\.|\\p{L}|\\$|\\s)+") |>
        stringr::str_replace(",", ".") |>
        as.numeric() |>
        max(na.rm = TRUE) |>
        unique()
    })
}
jjesusfilho/tjsp documentation built on May 4, 2024, 9:35 a.m.