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 ("C:/MODELACION AMBIENTAL/MODULO_CALIDAD_HIDRICA/ESPACIAL/6_CENTROS_SALUD.shp")
## Reading layer `6_CENTROS_SALUD' from data source 
##   `C:\MODELACION AMBIENTAL\MODULO_CALIDAD_HIDRICA\ESPACIAL\6_CENTROS_SALUD.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 42 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':   42 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.C.C. 15 DE NOVIEMBRE" "P.S. JUNACAS" "C.S. LA PINTADA" "C.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 42; 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_2008 <- readxl::read_excel ("C:/MODELACION AMBIENTAL/TABULARCARO/EDAS2008Solo42masCALOR.xls","Salud2008")
unionsalud_edas <-full_join(salud_espacial,edas_2008, 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
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
salud_2008 <- readxl::read_excel ("C:/MODELACION AMBIENTAL/TABULARCARO/EDAS2008Solo42masCALOR.xls","Calor")


hchart(salud_2008, "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
leaflet(unionsalud_edas) %>% 
  addTiles() %>% 
  addMarkers(clusterOptions = markerClusterOptions(),
             label = unionsalud_edas$NOMBRE_EST,
             labelOptions = labelOptions(noHide = T),
             popup = unionsalud_edas$TV15Aa59A)