library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
## Linking to GEOS 3.12.2, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE
peru1<-st_read("gadm41_PER_1.json")
## Reading layer `gadm41_PER_1' from data source 
##   `C:\Users\Pc1\Downloads\sesaion 3 graficos multivariados\gadm41_PER_1.json' 
##   using driver `GeoJSON'
## Simple feature collection with 26 features and 11 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -81.3307 ymin: -18.3518 xmax: -68.6522 ymax: -0.039
## Geodetic CRS:  WGS 84
a <- c(2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,4,5,6,7,2,3,4,5,6,7,8)
peru1 <- mutate(peru1,internet = a)

b <- c(1,3,3,4,6,3,7,1,1,4,5,4,5,2,7,8,5,9,7,9,1,1,5,2,7,8)
peru1 <- mutate(peru1,tasa_escolaridad = b)
peru1 <- st_as_sf(peru1,internet,tasa_escolaridad)
g1 <- ggplot() +
    geom_sf(data = peru1, aes(fill = internet)) +
    scale_fill_gradient(low = "yellow", high = "red") +
    labs(title="Acceso a internet en el Perú",
         fill="Internet")+
    xlim(x=c(-85,-68))+
    ylim(y=c(-20,5))+
    theme_bw(base_size = 10)



g2 <- ggplot() +
  geom_sf(data = peru1, aes(fill = tasa_escolaridad)) +
  scale_fill_gradient(low = "black", high = "skyblue") +
  labs(title="Tasa de escolaridad en el Perù",
       fill="Cantidad")+
  xlim(x=c(-85,-68))+
  ylim(y=c(-20,5))+
  theme_bw(base_size = 10)

library(patchwork)
g1+g2