Last active
November 7, 2023 21:50
-
-
Save beatrizmilz/356b763b008c50f9be768b89ae4c16ec to your computer and use it in GitHub Desktop.
Pequenas adaptações em funções úteis para lidar em R com formatos usados no Brasil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Função dplyr::arrange considerando locale pt_BR | |
# Contexto: https://blog.curso-r.com/posts/2023-03-06-ordenando-strings/ | |
arrange_br <- purrr::partial(dplyr::arrange, .locale = "pt_BR") | |
#' Função para converter números que estão em string nesse formato "1.706,23" | |
# para numeric | |
parse_number_br <- purrr::partial(readr::parse_number, | |
locale = readr::locale(decimal_mark = ",", | |
grouping_mark = ".")) | |
#' Função para converter datas que estão em string nesse formato "07/11/2023" | |
# para date | |
parse_date_br <- purrr::partial(readr::parse_date, format = "%d/%m/%Y") | |
# Função para remover acentos de texto | |
# Fonte: https://github.com/abjur/abjutils/blob/bbad0754e0196db058ddbebf520b824825eaf196/R/utils.R#L53-L63C1 | |
remover_acentos <- function(x) { | |
stringi::stri_trans_general(x, "Latin-ASCII") | |
} | |
# Outros úteis: | |
# Converter texto em title case usando as regras que usamos em português | |
# https://gist.github.com/jjesusfilho/454192db8356eb9c486a02698338221a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment