library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.0     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.1     
## ── 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(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(rmarkdown)
library(DescTools)
library(ggplot2)
getwd()
## [1] "/cloud/project/Act.LTI/conjunto_de_datos"
denue <- read_csv("denue_inegi_28_.csv", skip = 0, locale = locale(encoding = "latin1"))
## Rows: 148560 Columns: 42
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (33): clee, nom_estab, raz_social, nombre_act, per_ocu, tipo_vial, nom_v...
## dbl  (9): id, codigo_act, numero_ext, numero_int, cod_postal, cve_ent, telef...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
paste("Los registros son:", nrow(denue))
## [1] "Los registros son: 148560"
cat("Las variables son:", names(denue))
## Las variables son: id clee nom_estab raz_social codigo_act nombre_act per_ocu tipo_vial nom_vial tipo_v_e_1 nom_v_e_1 tipo_v_e_2 nom_v_e_2 tipo_v_e_3 nom_v_e_3 numero_ext letra_ext edificio edificio_e numero_int letra_int tipo_asent nomb_asent tipoCenCom nom_CenCom num_local cod_postal cve_ent entidad cve_mun municipio cve_loc localidad ageb manzana telefono correoelec www tipoUniEco latitud longitud fecha_alta
paste("Las variables que representan la ubigación geografica son: cod_postal, cve_ent, cve_mun, cve_loc, latitud y longitud")
## [1] "Las variables que representan la ubigación geografica son: cod_postal, cve_ent, cve_mun, cve_loc, latitud y longitud"
##Número de establecimientos por municipio. 
establecimientos_municipio <- denue %>%
  group_by(cve_mun) %>%
  summarise(n_establecimientos = n())
print(establecimientos_municipio)
## # A tibble: 43 × 2
##    cve_mun n_establecimientos
##    <chr>                <int>
##  1 001                    563
##  2 002                   1327
##  3 003                   8889
##  4 004                    256
##  5 005                    182
##  6 006                    117
##  7 007                    902
##  8 008                     69
##  9 009                   7167
## 10 010                     72
## # ℹ 33 more rows