This function adds the necessary geometry for drawing maps to a given data set downloaded by the covid19br::downloadCovid19() function.
Source
World map: https://CRAN.R-project.org/package=rnaturalearthdata
Shapefiles for Brazilian maps: https://www.ibge.gov.br/geociencias/downloads-geociencias.html
Brazilian DHI data: https://www.ipea.gov.br/ipeageo/bases.html
Arguments
- data
a data set downloaded using the covid19br::downloadCovid19() function.
- ...
further arguments passed to other methods.
Details
The function add_geo() was designed to work with the original names of the variables available in the dataset downloaded by the covid19br::downloadCovid19(). For this reason, this function must be used before any changes in the original names of the variables.
The development human index (DHI) variables (see full description below) are available at city level, and their average are computed for state and region levels.
Data dictionary (Brazilian data):
region: regions' names
state: states' names.
city: cities' names.
DHI: development human index.
EDHI: educational development human index.
LDHI: longevity development human index.
IDHI: income development human index.
pop: estimated population in 2019.
region_code: numerical code attributed to regions
state_code: numerical code attributed to states
mesoregion_code: numerical code attributed to mesoregions
microregion_code: numerical code attributed to microregions
city_code: numerical code attributed to cities
geometry: georeferenced data needed to plot maps.
area: area (in Km^2)
demoDens: demographic density.
Data dictionary (world data):
country: country's name
continent: continent's name
region: regions' names
subregion: subregion's name
pop: estimated population
pais: country's name in Portuguese
country_code: numerical code attributed to countries
continent_code: numerical code attributed to continents
region_code: numerical code attributed to regions
subregion_code: numerical code attributed to subregions
geometry: georeferenced data needed to plot maps.
Author
Fabio N. Demarqui fndemarqui@est.ufmg.br
Examples
# \donttest{
library(covid19br)
library(dplyr)
regions <- downloadCovid19(level = "regions")
#> Downloading COVID-19 data from the official Brazilian repository: https://covid.saude.gov.br/
#> Please, be patient...
#> Done!
regions_geo <- add_geo(regions)
#> Joining with `by = join_by(region, pop)`
glimpse(regions_geo)
#> Rows: 6,635
#> Columns: 18
#> $ region <chr> "Midwest", "Midwest", "Midwest", "Midwest", "Midwest", "M…
#> $ date <date> 2020-02-25, 2020-02-26, 2020-02-27, 2020-02-28, 2020-02-…
#> $ epi_week <int> 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11…
#> $ newCases <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 4, …
#> $ accumCases <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 5, 9, …
#> $ newDeaths <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ accumDeaths <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ newRecovered <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ newFollowup <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ pop <dbl> 16297074, 16297074, 16297074, 16297074, 16297074, 1629707…
#> $ DHI <dbl> 0.6894678, 0.6894678, 0.6894678, 0.6894678, 0.6894678, 0.…
#> $ EDHI <dbl> 0.5841416, 0.5841416, 0.5841416, 0.5841416, 0.5841416, 0.…
#> $ LDHI <dbl> 0.8224442, 0.8224442, 0.8224442, 0.8224442, 0.8224442, 0.…
#> $ IDHI <dbl> 0.6844893, 0.6844893, 0.6844893, 0.6844893, 0.6844893, 0.…
#> $ region_code <dbl> 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, …
#> $ area [km^2] 1611899 [km^2], 1611899 [km^2], 1611899 [km^2], 1611899 …
#> $ demoDens [1/km^2] 10.11048 [1/km^2], 10.11048 [1/km^2], 10.11048 [1/km^2…
#> $ geometry <POLYGON [°]> POLYGON ((-54.08399 -23.864..., POLYGON ((-54.083…
# }