library (stars)
## Warning: package 'stars' was built under R version 4.0.5
## Loading required package: abind
## Warning: package 'abind' was built under R version 4.0.3
## Loading required package: sf
## Warning: package 'sf' was built under R version 4.0.5
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(lubridate)
## Warning: package 'lubridate' was built under R version 4.0.5
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.5
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
salud_espacial <- st_read("G:/.shortcut-targets-by-id/1NcL9s4s8BCy0jh3YFweuj5BkWXQ9S5Xr/MODELACION2022/MODULO_CALIDAD_HIDRICA/ESPACIAL/6_CENTROS_SALUD.shp")
## Reading layer `6_CENTROS_SALUD' from data source 
##   `G:\.shortcut-targets-by-id\1NcL9s4s8BCy0jh3YFweuj5BkWXQ9S5Xr\MODELACION2022\MODULO_CALIDAD_HIDRICA\ESPACIAL\6_CENTROS_SALUD.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 39 features and 8 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -64.98158 ymin: -22.00043 xmax: -64.439 ymax: -21.342
## Geodetic CRS:  WGS 84
plot(salud_espacial)

str(salud_espacial)
## Classes 'sf' and 'data.frame':   39 obs. of  9 variables:
##  $ gml_id    : chr  "Establecimientos.1985" "Establecimientos.1986" "Establecimientos.1987" "Establecimientos.1988" ...
##  $ ID        : num  1985 1986 1987 1988 1989 ...
##  $ TIPO      : chr  "6" "4" "3" "3" ...
##  $ TIPO_DESCR: chr  "Centro de Salud con Camas" "Puesto de Salud" "Centro de Salud" "Centro de Salud" ...
##  $ NOMBRE_EST: chr  "C.S. 15 DE NOVIEMBRE" "P.S. JUNACAS" "P.S. LA PINTADA" "P.S. PAMPA REDONDA" ...
##  $ LAT       : num  -21.5 -21.4 -21.6 -21.7 -21.7 ...
##  $ LONG      : num  -64.7 -64.4 -64.6 -64.8 -64.9 ...
##  $ CODIGO_SNI: chr  "600002" "600003" "600004" "600005" ...
##  $ geometry  :sfc_POINT of length 39; first list element:  'XY' num  -64.7 -21.5
##  - attr(*, "sf_column")= chr "geometry"
##  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA
##   ..- attr(*, "names")= chr [1:8] "gml_id" "ID" "TIPO" "TIPO_DESCR" ...
edas_2005 <- readxl::read_excel ("G:/.shortcut-targets-by-id/1NcL9s4s8BCy0jh3YFweuj5BkWXQ9S5Xr/MODELACION2022/MODULO_CALIDAD_HIDRICA/SALUD/Salud_2009.xls","Sheet" )

unionsalud <- full_join(salud_espacial,edas_2005, by='NOMBRE_EST')

library(highcharter)
## Warning: package 'highcharter' was built under R version 4.0.5
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
salud_2005 <- readxl::read_excel ("G:/.shortcut-targets-by-id/1NcL9s4s8BCy0jh3YFweuj5BkWXQ9S5Xr/MODELACION2022/MODULO_CALIDAD_HIDRICA/SALUD/Salud_2009.xls","Hoja1")

hchart(salud_2005, "heatmap", hcaes(x = EDAD, y = NOMBRE_EST, value = VALOR)) %>% 
  hc_colorAxis(stops = color_stops(10, rev(RColorBrewer::brewer.pal(10, "Spectral")))) %>%  
  hc_tooltip(shared = TRUE, borderColor = "black", valueDecimals=2) %>% 
  hc_exporting(enabled = TRUE, filename = "salud_tarija")
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.0.5
paletasalud <- colorBin("magma", domain = unionsalud$TV15Aa59A,bins = 4)

leaflet(unionsalud) %>%
  addTiles() %>% 
  addCircleMarkers(fillColor = ~paletasalud(unionsalud$TV15Aa59A), radius = 1,
                   opacity = 1, fillOpacity = 1, label = unionsalud$TV15Aa59A)
leaflet(unionsalud) %>% 
  addTiles() %>% 
  addMarkers(clusterOptions = markerClusterOptions(),
             label = unionsalud$NOMBRE_EST,
             labelOptions = labelOptions(noHide = T),
             popup = unionsalud$TV15Aa59A)