Qué necesito

Paquetes de R

x <- c("rgdal","magrittr","dplyr","ggplot2","sf","tidyverse")

lapply(x, library, character.only = TRUE) # carga los paquetes requeridos
## [[1]]
## [1] "rgdal"     "sp"        "stats"     "graphics"  "grDevices" "utils"    
## [7] "datasets"  "methods"   "base"     
## 
## [[2]]
##  [1] "magrittr"  "rgdal"     "sp"        "stats"     "graphics"  "grDevices"
##  [7] "utils"     "datasets"  "methods"   "base"     
## 
## [[3]]
##  [1] "dplyr"     "magrittr"  "rgdal"     "sp"        "stats"     "graphics" 
##  [7] "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[4]]
##  [1] "ggplot2"   "dplyr"     "magrittr"  "rgdal"     "sp"        "stats"    
##  [7] "graphics"  "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[5]]
##  [1] "sf"        "ggplot2"   "dplyr"     "magrittr"  "rgdal"     "sp"       
##  [7] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
## [13] "base"     
## 
## [[6]]
##  [1] "forcats"   "stringr"   "purrr"     "readr"     "tidyr"     "tibble"   
##  [7] "tidyverse" "sf"        "ggplot2"   "dplyr"     "magrittr"  "rgdal"    
## [13] "sp"        "stats"     "graphics"  "grDevices" "utils"     "datasets" 
## [19] "methods"   "base"

Mapas de México del marco geoestadístico mexicano del sitio de datos abiertos del INEGI

Fuente de datos. Marco geoestadístico https://www.inegi.org.mx/temas/mg/#Descargas

https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/geografia/marcogeo/889463849568_s.zip

Geoentidades en https://file.coffee/u/P1uK0Tgpt4bMJf.csv

Municipios en https://file.coffee/u/NG5PUGradnGwyQ.csv

File Coffee: servicio web gratuito para compartir archivos fácilmente https://www.softandapps.info/2022/05/04/file-coffee-servicio-web-gratuito-para-compartir-archivos-facilmente/?utm_source=ReviveOldPost&utm_medium=social&utm_campaign=ReviveOldPost

#La ruta para el mapa de México se toma del Marcogeostadístico nacional

rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/"
geoentidades<-read.csv(paste0(rutamc,"marcogeoentidad.csv"),header=TRUE, sep=",",encoding="UTF-8")

municipios<-read.csv(paste0(rutamc,"municipios.csv"),header=TRUE, sep=",",encoding="latin")

municipios <-subset(municipios,municipios$NOM_ENT %in% c("Coahuila de Zaragoza"))
municipios <-subset(municipios,municipios$NOM_MUN %in% c("Torreón"))
titulmun<-municipios$NOM_MUN
nummun<-municipios$MUN

   
rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/889463807469_s"


codent<-substr(geoentidades$NUM_ENT,1,2)
codent<-sprintf("%02d%s", as.numeric(gsub("[^0-9]+", "", codent)), gsub("[0-9]+", "", codent))


geoentidades$COD_ENT<-codent
geoentidades <-subset(geoentidades,geoentidades$NOM_ENT %in% c("Coahuila de Zaragoza"))
codent<-geoentidades$COD_ENT


rutamc<-"D:/Documents/Claudia/Midropbox/Investigacion y escritos/Censo2020/889463807469_s/"
filename<-geoentidades$ARCHENT

filemun<-paste0(geoentidades$COD_ENT,"mun")
#fileloc<-paste0(geoentidades$COD_ENT,"a")
#filemza<-paste0(geoentidades$COD_ENT,"m")
#fileeje<-paste0(geoentidades$COD_ENT,"e")
url<-paste0(rutamc,filename,".zip")
temp2 <- tempfile()
unzip(url, exdir = temp2)
rut<-file.path(temp2)
rutamun<-paste0(rut,"/conjunto_de_datos")

basemapamun <- readOGR(rutamun,filemun, use_iconv = TRUE, encoding = "latin1")
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\Claudia.Guerrero\AppData\Local\Temp\RtmpsPopBO\file25b05af53c8\conjunto_de_datos", layer: "05mun"
## with 38 features
## It has 4 fields
snummun<-sprintf("%03d%s", as.numeric(gsub("[^0-9]+", "", nummun)), gsub("[0-9]+", "", nummun))

#basemapamun<-subset(basemapamun,basemapamun$CVE_MUN %in% c(snummun))

map <- ggplot() +
  geom_polygon(data = basemapamun, aes(x = long, y = lat, group = group), colour = "black", fill = "white", size = .8)+ coord_map("azequidist")

map + theme_void()

proj4string(basemapamun)
## [1] "+proj=lcc +lat_0=12 +lon_0=-102 +lat_1=17.5 +lat_2=29.5 +x_0=2500000 +y_0=0 +ellps=GRS80 +units=m +no_defs"
shpfilemun <- spTransform(basemapamun, 
CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))

map <- ggplot() +
  geom_polygon(data = shpfilemun, aes(x = long, y = lat, group = group), colour = "black", fill= "white", size = .5)+ coord_map()

map + theme_void()