class: center, middle, inverse, title-slide .title[ # Hotspots de la Transmisión de Dengue en R ] .author[ ### Felipe Antonio Dzul Manzanilla ] .date[ ### 2022: Last compiled 2022-11-05 ] --- class: left, top
# **Cálculo de los Hotspots de Dengue** .pull-left[
] .pull-right[
] --- # **Geocodificación de las bases de dengue en R** <hr style="height:2px;border-width:0;color:#330019;background-color:#330019"> ## 0. Darse de alta en el servicio de Geocoding API de google ## 1. Subir las bases de dengue. ## 2. Geocodificar las bases de dengue. ## 3. Unir las bases de dengue. --- # **Geocodificación** .panelset[ .panel[.panel-name[Paso 1. Load dataset] ```r # Step 1. Subir la base de datos de dengue de la semana pasada ##### # y <- denhotspots::read_dengue_dataset() # Step 2. Subir la base de datos de dengue de la semana actual #### # x <- denhotspots::read_dengue_dataset() # Step 3. extraer los casos (ids) no geocodificados de la semana actual ### #z <- x |> # dplyr::filter(!VEC_ID %in% c(y$VEC_ID)) |> # dplyr::arrange(VEC_ID) # Step 4. guardar los resultados #### #write.csv(z, file = "positive_denmx_2022_10_17.csv") ``` ] .panel[.panel-name[Paso 2. Geocoding] ```r # Step 1. apply the vector addreses #### #addresses <- denhotspots::data_geocoden(infile = "positive_denmx_2022_10_17", # data = FALSE, # sinave_new = TRUE) # Step 2. text manipulation #### #stringr::str_subset(addresses, "(?<=Colonia ).+(?= CENTRO)") #addresses <- stringr::str_replace_all(addresses, # pattern = " VER,", # replacement = " ,") # Step 3. geocoding ### #library(ggmap) #denhotspots::geocoden(infile = "positive_denmx_2022_10_17") # Step 4. load the dengue geocoded & dengue dataset ##### #z <- readRDS("C:/Users/HOME/OneDrive/proyects/geocoding_mex/2022/positive_denmx_2022_10_17_temp_geocoded.rds") #data <- denhotspots::data_geocoden(infile = "positive_denmx_2022_10_17", # data = TRUE, # sinave_new = TRUE) #Step 5. save the results ##### #denhotspots::save_geocoden(x = z, # y = data, # directory = "9.RData_geocoded", # loc = "positive_denmx_2022_10_17") ``` ] .panel[.panel-name[Paso 3. Save the dataset] ```r # Step 1. load geocoded dengue dataset of the current week ### #load("C:/Users/HOME/OneDrive/proyects/geocoding_mex/2022/9.RData_geocoded/geo_den_mx_26_sonora_2022_09_26.RData") #y <- y[stringr::str_which(y$formatted_address, " Sonora|Son"),] # Step 2 load geocoded dengue dataset of the last week ### # load("C:/Users/HOME/OneDrive/proyects/geocoding_mex/2022/9.RData_geocoded/den22_sonora.RData") # step 3. row binding #### # z <- rbind(z, y) # Step 4. save the results #### #save(z, file = "9.RData_geocoded/den22_sonora.RData") ``` ] ] --- # Identificación de los Hotspots en R <hr style="height:2px;border-width:0;color:#330019;background-color:#330019"> .panelset[ .panel[.panel-name[Dataset] ```r # Step 1. load the dengue geocoded dataset #### load("C:/Users/HOME/OneDrive/proyects/priority_research_projects/hotspots_high_risk_localities_138/8.RData/geocoded_dataset.RData") ``` ] .panel[.panel-name[Extract Locality] ```r # Step 2. extract the locality ##### x <- rgeomex::extract_ageb(locality = c("Guadalajara", "Zapopan", "Tlaquepaque", "Tonalá"), cve_geo = "14") ``` ] .panel[.panel-name[Cases by AGEB] ```r library(magrittr) z <- denhotspots::point_to_polygons(x = y, y = x$ageb, ids = names(x$ageb)[-10], time = ANO, coords = c("long", "lat"), crs = 4326, dis = "DENV") ``` ] .panel[.panel-name[Hotspots] ```r hotspots <- denhotspots::gihi(x = z, id = names(z)[c(1:9)], time = "year", dis = "DENV", gi_hi = "gi", alpha = 0.95) ``` ] ] --- # Visualización <hr style="height:2px;border-width:0;color:#330019;background-color:#330019"> .panelset.sideways[ .panel[.panel-name[Static Map Code] ```r denhotspots::staticmap_intensity(x = hotspots, pal = rcartocolor::carto_pal, pal_name = TRUE, name = "OrYel", breaks = 1, dir_pal = -1, x_leg = 0.5, y_leg = 0.1, ageb = TRUE) ``` ] .panel[.panel-name[Static Map] <!-- --> ] .panel[.panel-name[Interactive Map Code] ```r source("C:/Users/HOME/Dropbox/r_developments/r_dashboards/github_pages/test_dashboard/3.Functions/hotspots_map.R") hotspots_map(cve_ent = "14", locality = c("Guadalajara", "Zapopan", "Tlaquepaque", "Tonalá"), hotspots = hotspots, static_map = FALSE) ``` ] .panel[.panel-name[Interactive Map]
] ] --- # Dios Botic! <hr style="height:2px;border-width:0;color:#330019;background-color:#330019"> - ***Bio*** : https://fdzul.github.io/web_site_fadm/ - ***email*** : felipe.dzul.m@gmail.com - ***celular*** : 228 229 3419 - ***slides***: https://animated-longma-729cee.netlify.app/talks/hotspots_cases_r/#1 .footnote[La presentación fue creada via [**xaringan**](https://github.com/yihui/xaringan), [**revealjs**](https://revealjs.com/), [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), & [R Markdown](https://rmarkdown.rstudio.com) en [R]() & [RStudio](2.R_Scripts/libs/rstudio_leaflet/rstudio_leaflet.css).]