ruta <- "C:/Users/ENE/Documents/ejerciciosR"
setwd (ruta)
library(readr)
datosINEGI <- read_csv("resultados_ageb_urbana_10_cpv2010.csv")
## Parsed with column specification:
## cols(
## .default = col_character(),
## entidad = col_integer(),
## pobtot = col_integer(),
## vivtot = col_integer()
## )
## See spec(...) for full column specifications.
# Cuantas observaciones tiene el conjunto de datos
print(paste("El numero total de registros son: ",length(datosINEGI$nom_ent)))
## [1] "El numero total de registros son: 30876"
#Mediante la funcion length() y una columna del dataframe se obtiene el numero de registros, tambien se puede utilizar la funcion nrow()
#Cuantas variables contienen el conjunto de datos
print(paste("El numero total de colunas son",ncol(datosINEGI)))
## [1] "El numero total de colunas son 198"
#Mediante la funcion ncol se obtiene el numero de columnas del data frame
#Determinar un nuevo data frame solo con los municipios de Lerdo, Gomez Palacio, Durango, Canatl??n, Santiago Papasquiaro, Guadalupe Victoria, Vicente Guerrero , Pueblo Nuevo y Nuevo Ideal. Incluir todas las columnas
Filtro.datosINEGI<-datosINEGI[which(datosINEGI$nom_loc=="Lerdo"|datosINEGI$nom_loc=="G??mez Palacio"|datosINEGI$nom_loc=="Victoria de Durango"|datosINEGI$nom_loc=="Canatl??n"|datosINEGI$nom_loc=="Santiago Papasquiaro"|datosINEGI$nom_loc=="Guadalupe Victoria"|datosINEGI$nom_loc=="Vicente Guerrero"|datosINEGI$nom_loc=="El Salto"|datosINEGI$nom_loc=="Nuevo Ideal"),]
# Se realiza la columna de acuerdo con los parametros establesidos y asignados a un nuevo data frame
#Mostrar solo los primeros 6 registros
head(Filtro.datosINEGI) #con la instruccion head muestra los primeros 6 registros
## # A tibble: 6 x 198
## entidad nom_ent mun nom_mun loc nom_loc ageb mza pobtot pobmas
## <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
## 1 10 Durango 005 Durango 0001 Victoria ~ 0015 001 86 45
## 2 10 Durango 005 Durango 0001 Victoria ~ 0015 002 7 3
## 3 10 Durango 005 Durango 0001 Victoria ~ 0015 003 71 37
## 4 10 Durango 005 Durango 0001 Victoria ~ 0015 004 87 42
## 5 10 Durango 005 Durango 0001 Victoria ~ 0015 005 113 53
## 6 10 Durango 005 Durango 0001 Victoria ~ 0015 006 69 35
## # ... with 188 more variables: pobfem <chr>, p_0a2 <chr>, p_0a2_m <chr>,
## # p_0a2_f <chr>, p_3ymas <chr>, p_3ymas_m <chr>, p_3ymas_f <chr>,
## # p_5ymas <chr>, p_5ymas_m <chr>, p_5ymas_f <chr>, p_12ymas <chr>,
## # p_12ymas_m <chr>, p_12ymas_f <chr>, p_15ymas <chr>, p_15ymas_m <chr>,
## # p_15ymas_f <chr>, p_18ymas <chr>, p_18ymas_m <chr>, p_18ymas_f <chr>,
## # p_3a5 <chr>, p_3a5_m <chr>, p_3a5_f <chr>, p_6a11 <chr>,
## # p_6a11_m <chr>, p_6a11_f <chr>, p_8a14 <chr>, p_8a14_m <chr>,
## # p_8a14_f <chr>, p_12a14 <chr>, p_12a14_m <chr>, p_12a14_f <chr>,
## # p_15a17 <chr>, p_15a17_m <chr>, p_15a17_f <chr>, p_18a24 <chr>,
## # p_18a24_m <chr>, p_18a24_f <chr>, p_15a49_f <chr>, p_60ymas <chr>,
## # p_60ymas_m <chr>, p_60ymas_f <chr>, rel_h_m <chr>, pob0_14 <chr>,
## # pob15_64 <chr>, pob65_mas <chr>, prom_hnv <chr>, pnacent <chr>,
## # pnacent_m <chr>, pnacent_f <chr>, pnacoe <chr>, pnacoe_m <chr>,
## # pnacoe_f <chr>, pres2005 <chr>, pres2005_m <chr>, pres2005_f <chr>,
## # presoe05 <chr>, presoe05_m <chr>, presoe05_f <chr>, p3ym_hli <chr>,
## # p3ym_hli_m <chr>, p3ym_hli_f <chr>, p3hlinhe <chr>, p3hlinhe_m <chr>,
## # p3hlinhe_f <chr>, p3hli_he <chr>, p3hli_he_m <chr>, p3hli_he_f <chr>,
## # p5_hli <chr>, p5_hli_nhe <chr>, p5_hli_he <chr>, phog_ind <chr>,
## # pcon_lim <chr>, pclim_mot <chr>, pclim_vis <chr>, pclim_leng <chr>,
## # pclim_aud <chr>, pclim_mot2 <chr>, pclim_men <chr>, pclim_men2 <chr>,
## # psin_lim <chr>, p3a5_noa <chr>, p3a5_noa_m <chr>, p3a5_noa_f <chr>,
## # p6a11_noa <chr>, p6a11_noam <chr>, p6a11_noaf <chr>, p12a14noa <chr>,
## # p12a14noam <chr>, p12a14noaf <chr>, p15a17a <chr>, p15a17a_m <chr>,
## # p15a17a_f <chr>, p18a24a <chr>, p18a24a_m <chr>, p18a24a_f <chr>,
## # p8a14an <chr>, p8a14an_m <chr>, p8a14an_f <chr>, p15ym_an <chr>,
## # p15ym_an_m <chr>, ...