12/2/2022

Intro & Objective

This was the final assignment for the Coursera Data Products Course.

Objetive: Build a Shiny app that tells what is the nearest hospital location for the user based on their current ip address.

You can interact with the Shiny App Here: Shiny App

Link to Github Repo: Github Repo

note:: The code only contains ui.R and server.R, since the app requires API keys to work and those scripts were not included for security purposes (functions.R file in the server.R script).

Methodology

The app only works for people currently in El Salvador.

  1. It uses a database of public hospitals available in the web with geolocation points (latitude and longitud).
  2. It uses custom functions to calculate the straight distance between the user and all the available hospitals and filters the 3 with the minimum distance in kms.
  3. This filtered df is now used to call the Google Distance Matrix API and now the criteria to choose the nearest hospital is the time required to arrive to the destination.
  4. Points are plotted in the map.

Glimpse Into Data

hosp=readRDS(file = 'hospitals/data/hospitales.rds')
head(hosp %>% select(latitude,longitude,name))
## # A tibble: 6 x 3
##   latitude longitude name                                    
##      <dbl>     <dbl> <chr>                                   
## 1     13.3     -88.4 Clínica del Seguro Social               
## 2     13.7     -89.2 Clínica Comunal                         
## 3     13.5     -88.9 Unidad de Salud                         
## 4     13.5     -88.3 Cruz Roja                               
## 5     13.7     -89.2 Fosalud San Jacinto                     
## 6     14.0     -88.9 Unidad de Salud - San Miguel de Mercedes
dim(hosp)
## [1] 59 38

Example

This is an example of the app working:

IP address has been blurred out

Example for people outside of El Salvador

This is an example of the app not working:

US Image