185 days ago · Science · hide · Fediverse post

Há anos eu tenho um documento no meu Standard Notes só com as funções e snippets que eu mais uso em R, uma forma mais recorrente de copiar e colar coisas eficientes.Compartilho abaixo:Remove notação científicaoptions(scipen=999)Calcula percentual de contagem em relação ao total (dplyr)mutate(pct_total = round((n/sum(n))*100,1))Calcula variação percentual em relação ao valor imediatamente anterior (dplyr)mutate(var_mes = ((soma/lag(soma) - 1) * 100)) %>%Conserta escala Y no ggplot (ggplot2)scale_y_continuous(labels=function(x) format(x, big.mark = ",", scientific = FALSE))Ajusta escala X para datas no ggplot (ggplot2 + scales)scale_x_date(breaks = scales::pretty_breaks(n = 10))scale_x_date(date_breaks = "1 month", date_labels = "%b %Y")Ajusta ângulo da legenda para data (ggplot2)theme(axis.text.x=element_text(angle=60, hjust=1))Deflaciona valores com o pacote deflateBRPacote por Fernando Meireles e Denisson Silva — https://github.com/meirelesff/deflateBRd$valor_novo <-…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town