knitr::opts_chunk$set( message = FALSE, warning = FALSE, collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", fig.width = 8, fig.height = 8, dpi = 300 )
The goal of brnome is to ...
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("italocegatta/brnome")
This is a basic example which shows you how to solve a common problem:
library(brnome) library(brmap) library(tidyverse) joao_freq <- brnome_freq(nome = "joao") joao_freq
brnome_freq(nome = "joao", sexo = "m")
brnome_freq(nome = "joao", localidade_cod = 5103403)
brnome_freq(nome = "joao", localidade_cod = 51)
joao_estado <- localidades %>% filter(tipo == "Estado") %>% mutate( freq = map( localidade, ~brnome_freq(nome = "joao", localidade_cod = .x) ) ) %>% select(freq) %>% unnest() joao_estado
joao_estado %>% group_by(nascimento_decada) %>% summarise(frequencia = sum(frequencia)) %>% ggplot(aes(nascimento_decada, frequencia)) + geom_line(size = 1) + geom_point(shape = 21, color = "#35978f", fill = "#80cdc1", size = 7, stroke = 2) + labs(x = "Década de nascimento", y = "Frequência do nome joao") + scale_x_continuous(breaks = seq(1900, 2020, 10)) + scale_y_continuous(limits = c(0, NA), labels = scales::unit_format(unit = "k", scale = 1e-3)) + theme_bw(16)
joao_estado %>% left_join(brmap_estado_simples, by = c("localidade_nome" = "estado_nome")) %>% st_as_sf() %>% ggplot(aes(fill = frequencia)) + geom_sf(color = "white") + labs(fill = "Frequência do nome joao") + scale_fill_distiller( palette = "Greens", direction = 1, labels = scales::unit_format(unit = "k", scale = 1e-3) ) + theme_bw() + theme(legend.position = "bottom", legend.justification = "right") + guides(fill = guide_colorbar(barwidth = 15, title.position = "top"))
rank_decada <- map_dfr(seq(1930, 2000, 10), ~brnome_rank(decada = .x)) rank_decada %>% ggplot(aes(decada, ranking, fill = frequencia, label = nome)) + geom_line(aes(group = nome), alpha = 0.5) + geom_label(color = "black", size = 3) + #facet_wrap(~sexo, labeller = labeller(sexo = c("F" = "Feminino", "M" = "Masculino"))) + labs(x = "Décade de nascimento", y = "Ranking", fill = "Frequência") + scale_x_continuous(breaks = seq(1930, 2000, 10)) + scale_y_reverse(breaks = 1:20) + scale_fill_distiller( palette = "PuBuGn", direction = 1, labels = scales::unit_format(unit = "k", scale = 1e-3) ) + theme_bw() + theme(legend.position = "bottom", legend.justification = "right") + guides(fill = guide_colorbar(barwidth = 20, title.position = "top"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.