https://github.com/brunomontezano/continentesbr
🌍 Scrape data from countries and capitals through Wikipedia, BrasilEscola and SportHistoire in a tidy manner. R package for study purposes.
https://github.com/brunomontezano/continentesbr
brasil brazil brazilian-portuguese data-cleaning geografia geographic-data geography ggplot2 r r-package r-packages raspagem-de-dados web-scraping wikipedia
Last synced: 4 months ago
JSON representation
🌍 Scrape data from countries and capitals through Wikipedia, BrasilEscola and SportHistoire in a tidy manner. R package for study purposes.
- Host: GitHub
- URL: https://github.com/brunomontezano/continentesbr
- Owner: brunomontezano
- License: gpl-3.0
- Created: 2021-09-10T02:36:40.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-20T05:16:51.000Z (about 4 years ago)
- Last Synced: 2025-03-01T00:33:11.497Z (8 months ago)
- Topics: brasil, brazil, brazilian-portuguese, data-cleaning, geografia, geographic-data, geography, ggplot2, r, r-package, r-packages, raspagem-de-dados, web-scraping, wikipedia
- Language: R
- Homepage:
- Size: 299 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://github.com/brunomontezano/continentesBR/actions)
[](https://travis-ci.com/brunomontezano/continentesBR)
[](https://doi.org/10.5281/zenodo.5516778)## Resumo / Overview
O objetivo deste pacote é adquirir os dados contidos em páginas da Wikipedia,
BrasilEscola e SportHistoire e, então, disponibilizar de forma acessível para quem
quiser uma tabela limpa sobre dados geográficos dos países rapidamente, em
português brasileiro.The purpose of this package is to acquire the data contained in pages from Wikipedia, BrasilEscola and SportHistoire and then make it accessible to anyone who wants a clean table of countries' geographic data quickly, in Brazilian Portuguese.
## Instalação / Installation
Você pode instalar a última versão do pacote `continentesBR` através do seguinte código:
You can install the latest version of the `continentesBR` package via the following code:
``` r
# install.packages("remotes")
remotes::install_github("brunomontezano/continentesBR")
```## Exemplos / Examples
Este é o exemplo de função presente na atual versão do pacote, usada para
gerar uma tabela (`tibble`) com nomes de países, capitais, continentes,
área em km2, população e densidade populacional:This is the example of a function present in the current version of the package, used to generate a table (`tibble`) with names of countries, capitals, continents, area in km2, population and population density (function name in english would mean `generate_table()`):
```{r}
# Caso prefira não carregar o pacote, utilizar como continentesBR::gerar_tabela()# If you prefer not to load the package, use as continentsBR::gerar_tabela()
library(continentesBR)
gerar_tabela()
```-----
Podemos exportar a tabela para o nosso computador através dos argumentos `salvar` e
`formato`:We can export the table to our computer via the `salvar` (`save`)
and `formato` (`format`) arguments:```{r, eval = FALSE}
# Como comentado anteriormente, pode-se utilizar a função através dos "::"
# Neste exemplo, a tibble será salva em um arquivo
# chamado "tabela_continentes.xlsx" no diretório de trabalho atual# As mentioned before, you can use the function through "::"
# In this example, the tibble will be saved to a file
# called "tabela_continentes.xlsx" in the current working directory
continentesBR::gerar_tabela(salvar = TRUE, formato = "excel")
```-----
Ou também realizar qualquer manipulação ou visualização posterior que se faça necessária:
Or carry out any data manipulation or visualization
that may be necessary:```{r}
# Quantos países existem em cada continente?
# How many countries are there on each continent?
library(magrittr)
gerar_tabela() %>%
dplyr::count(continente) %>%
ggplot2::ggplot() +
ggplot2::aes(x = continente, y = n, fill = as.factor(continente)) +
ggplot2::geom_col() +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none") +
ggplot2::labs(x = "Continente", y = "Número de países") +
#ggplot2::labs(x = "Continent", y = "Number of countries") +
ggplot2::coord_flip()
```-----
```{r}
# Existe associação entre área e tamamnho da população?
# Is there an association between area and population size?
gerar_tabela() %>%
dplyr::filter(pop < 1e9 & !is.na(area_km2)) %>%
ggplot2::ggplot() +
ggplot2::aes(x = area_km2, y = pop, color = continente) +
ggplot2::geom_point(size = 3, alpha = 0.6) +
ggplot2::scale_x_log10(label = scales::label_number(
big.mark = ".", decimal.mark = ",")) +
ggplot2::scale_y_continuous(label = scales::label_number(big.mark = ".",
decimal.mark = ",")) +
ggplot2::labs(x = bquote("Área (km"^2*")"), # Area
y = "População", # Population
color = "Continente") + # Continent
ggplot2::theme_minimal()
```## Agradecimentos / Acknowledgement
Agradeço ao designer [Guilherme Bueno](https://guilhermebuenodesign.github.io/)
pela elaboração do logo do pacote.I would like to thank the designer [Guilherme Bueno](https://guilhermebuenodesign.github.io/) for creating
the package logo.