Las librerías son útiles para realizar funciones especiales. La especialización de paquetes es más rápida en R que en otros programas por ser un software libre.
Vamos a instalar el paquete “foreign”, como su nombre lo indica, nos permite leer elementos “extranjeros” en R. Es sumamente útil porque nos permite leer casi todos los formatos, sin necesidad de usar paquetes especializados como StatTransfer.
Para instalar las paqueterías usamos el siguiente comando “install.packages()” Checa que adentro del paréntesis va el nombre de la librería, con comillas. Si estamos trabajando en la computadora no es necesario poner la opción repos = “http://cran.us.r-project.org”."
Con la opción “dependencies = TRUE” R nos instalará no sólo la librería o paquete que estamos pidiendo, sino todo aquellos paquetes que necesite la librería en cuestión. Muchas veces los diseños de los paquetes implican el uso de algún otro anterior. Por lo que poner esta sentencia nos puede ahorrar errores cuando estemos usando el paquete. Piensa que esto es similar a cuando enciendes tu computadora y tu sistema operativo te pide que mantengas las actualizaciones.
install.packages("foreign", repos = "http://cran.us.r-project.org", dependencies = TRUE)
## Installing package into '/Users/anaescoto/Library/R/3.3/library'
## (as 'lib' is unspecified)
##
## There is a binary version available but the source version is
## later:
## binary source needs_compilation
## foreign 0.8-69 0.8-71 TRUE
## installing the source package 'foreign'
## Warning in install.packages("foreign", repos = "http://cran.us.r-
## project.org", : installation of package 'foreign' had non-zero exit status
Este proceso no hay que hacerlo siempre. Si no sólo la primera vez. Una vez instalado un paquete de librería, la llamamos con el comando “library”
library(foreign)
Ahora ya tenemos nuestra librería y la podemos usar. Para que sea más sencillo vamos a establecer dónde tenemos nuestro directorio. Esto se hace con el comando setwd, de set work directory
setwd("/Users/anaescoto/Dropbox/DGAPA/2018/RMD")
Hoy vamos llamar el archivo. Este archivo es justo como se puede descargar desde Inegi. Inegi tiene muchos formatos de publicación. No obstante, el que es común a todos es el dbf. Al objeto enigh_concentrado se le asignará lo que leemos de archivo dbf. Actualmente la base se encuesta en este link link La base se puede descargar desde el sitio del curso, o bien, desde este link directo aquí
Una ves que descargues la base, colocala en la carpeta de trabajo para que sea más sencillo de revisar
enigh_concentrado <- read.dbf("concentradohogar.dbf")
Vamos a ver nuestra base de datos. Esto es como la “vista de datos” de SPSS o bien lo que veríamos con el “browse” en STATA
#View(enigh_concentrado)
También con “head, vemos las primeras 6 líneas de la base de datos
head(enigh_concentrado)
## folioviv foliohog ubica_geo ageb tam_loc est_socio est_dis upm
## 1 0100003801 1 010010001 023-3 1 4 003 0000010
## 2 0100003802 1 010010001 023-3 1 4 003 0000010
## 3 0100003803 1 010010001 023-3 1 4 003 0000010
## 4 0100003804 1 010010001 023-3 1 4 003 0000010
## 5 0100003805 1 010010001 023-3 1 4 003 0000010
## 6 0100010401 1 010010001 028-6 1 4 003 0000020
## factor clase_hog sexo_jefe edad_jefe educa_jefe tot_integ hombres
## 1 247 2 1 33 10 2 1
## 2 247 2 1 29 10 2 1
## 3 247 2 1 47 10 6 2
## 4 247 3 2 29 11 3 0
## 5 247 2 1 55 10 2 2
## 6 200 3 1 66 10 5 2
## mujeres mayores menores p12_64 p65mas ocupados percep_ing perc_ocupa
## 1 1 2 0 2 0 2 2 2
## 2 1 2 0 2 0 2 2 2
## 3 4 3 3 3 0 1 1 1
## 4 3 3 0 3 0 2 3 2
## 5 0 2 0 2 0 1 1 1
## 6 3 4 1 2 2 4 4 4
## ing_cor ingtrab trabajo sueldos horas_extr comisiones aguinaldo
## 1 100696.70 100696.70 100696.70 97377.04 0 0 3319.66
## 2 146616.16 144157.15 144157.15 91475.40 0 0 10819.67
## 3 94622.95 82622.95 82622.95 82622.95 0 0 0.00
## 4 58278.65 34672.11 34672.11 33442.61 0 0 1229.50
## 5 57295.07 42295.07 42295.07 35409.83 0 0 6885.24
## 6 149554.70 30986.39 30986.39 26706.51 0 0 3546.19
## indemtrab otra_rem remu_espec negocio noagrop industria comercio
## 1 0 0.00 0.00 0 0 0 0
## 2 0 7622.95 34239.13 0 0 0 0
## 3 0 0.00 0.00 0 0 0 0
## 4 0 0.00 0.00 0 0 0 0
## 5 0 0.00 0.00 0 0 0 0
## 6 0 733.69 0.00 0 0 0 0
## servicios agrope agricolas pecuarios reproducc pesca otros_trab rentas
## 1 0 0 0 0 0 0 0 0
## 2 0 0 0 0 0 0 0 0
## 3 0 0 0 0 0 0 0 0
## 4 0 0 0 0 0 0 0 0
## 5 0 0 0 0 0 0 0 0
## 6 0 0 0 0 0 0 0 0
## utilidad arrenda transfer jubilacion becas donativos remesas bene_gob
## 1 0 0 0.00 0.0 0 0.00 0 0.00
## 2 0 0 2459.01 0.0 0 2459.01 0 0.00
## 3 0 0 0.00 0.0 0 0.00 0 0.00
## 4 0 0 23606.54 0.0 0 23606.54 0 0.00
## 5 0 0 0.00 0.0 0 0.00 0 0.00
## 6 0 0 104052.19 82173.9 0 0.00 0 3326.08
## transf_hog trans_inst estim_alqu otros_ing gasto_mon alimentos
## 1 0.00 0.00 0.00 0 46599.96 10621.89
## 2 0.00 0.00 0.00 0 82427.75 14637.70
## 3 0.00 0.00 12000.00 0 54792.51 21214.07
## 4 0.00 0.00 0.00 0 42452.37 14567.00
## 5 0.00 0.00 15000.00 0 47589.29 16097.03
## 6 489.12 18063.09 14516.12 0 35760.55 14181.17
## ali_dentro cereales carnes pescado leche huevo aceites tuberculo
## 1 9953.32 1763.94 1920.33 0.00 1130.13 0.00 0.00 0.00
## 2 6280.59 944.97 578.57 0.00 951.40 674.99 0.00 0.00
## 3 13114.08 1877.10 2802.85 0.00 3381.40 244.28 334.28 192.85
## 4 9938.43 1285.67 269.99 2571.42 899.99 629.99 0.00 0.00
## 5 10697.04 1092.83 989.99 0.00 0.00 0.00 0.00 0.00
## 6 11095.47 1645.66 3355.66 0.00 2712.79 539.99 0.00 0.00
## verduras frutas azucar cafe especias otros_alim bebidas ali_fuera
## 1 154.28 488.56 449.99 0 1013.13 1580.13 1452.83 668.57
## 2 179.98 0.00 0.00 0 0.00 2774.54 176.14 8357.11
## 3 1465.66 1465.68 0.00 0 0.00 514.28 835.70 8099.99
## 4 411.41 0.00 0.00 0 0.00 3471.40 398.56 4628.57
## 5 0.00 0.00 0.00 0 0.00 6248.54 2365.68 5399.99
## 6 192.85 938.54 0.00 0 231.42 1478.56 0.00 3085.70
## tabaco vesti_calz vestido calzado vivienda alquiler pred_cons agua
## 1 0 1888.03 1888.03 0.00 10543.50 8100 450 750.00
## 2 0 9415.70 5673.88 3741.82 9526.50 9000 0 291.00
## 3 0 3463.01 2386.93 1076.08 930.00 0 0 630.00
## 4 0 782.60 0.00 782.60 15825.00 12000 0 600.00
## 5 0 1173.90 1173.90 0.00 3155.00 0 125 585.00
## 6 0 0.00 0.00 0.00 3193.54 0 150 943.54
## energia limpieza cuidados utensilios enseres salud atenc_ambu
## 1 1243.5 15343.01 1425.00 0.00 13918.01 983.13 983.13
## 2 235.5 8407.35 1524.00 342.39 6540.96 4397.26 1589.66
## 3 300.0 9277.60 1206.00 694.56 7377.04 1447.82 0.00
## 4 3225.0 1905.00 1905.00 0.00 0.00 684.77 684.77
## 5 2445.0 6483.33 5802.00 234.78 446.55 0.00 0.00
## 6 2100.0 1729.65 1695.42 0.00 34.23 0.00 0.00
## hospital medicinas transporte publico foraneo adqui_vehi mantenim
## 1 0.0 0.00 3450.00 0 0.00 0 2100.00
## 2 2807.6 0.00 10367.19 0 2754.08 0 5363.11
## 3 0.0 1447.82 13050.00 0 0.00 0 9000.00
## 4 0.0 0.00 6420.00 0 0.00 0 1800.00
## 5 0.0 0.00 2940.00 0 0.00 0 1440.00
## 6 0.0 0.00 11723.12 0 0.00 0 9290.32
## refaccion combus comunica educa_espa educacion esparci paq_turist
## 1 0.00 2100.00 1350.0 900.00 0.00 900.00 0
## 2 2213.11 3150.00 2250.0 2213.11 0.00 2213.11 0
## 3 0.00 9000.00 4050.0 600.00 0.00 600.00 0
## 4 0.00 1800.00 4620.0 450.00 0.00 450.00 0
## 5 0.00 1440.00 1500.0 9267.00 5067.00 4200.00 0
## 6 0.00 9290.32 2432.8 2045.52 1115.52 930.00 0
## personales cuida_pers acces_pers otros_gas transf_gas percep_tot
## 1 2870.40 1395.00 0.00 1475.40 0.00 0.00
## 2 18472.01 15303.00 3081.51 87.50 4990.93 880.43
## 3 4810.01 1101.00 0.00 3709.01 0.00 0.00
## 4 1818.00 1818.00 0.00 0.00 0.00 0.00
## 5 8473.03 3555.00 0.00 4918.03 0.00 0.00
## 6 2887.55 2412.55 0.00 475.00 0.00 8559.77
## retiro_inv prestamos otras_perc ero_nm_viv ero_nm_hog erogac_tot
## 1 0 0 0.00 0 0.00 17508.19
## 2 0 0 0.00 0 880.43 5360.65
## 3 0 0 0.00 0 0.00 23778.68
## 4 0 0 0.00 0 0.00 8852.45
## 5 0 0 0.00 0 0.00 0.00
## 6 0 0 8559.77 0 0.00 0.00
## cuota_viv mater_serv material servicio deposito prest_terc pago_tarje
## 1 0 98.36 98.36 0.00 0 0 17409.83
## 2 0 0.00 0.00 0.00 0 0 5360.65
## 3 0 172.13 0.00 172.13 0 0 23606.55
## 4 0 0.00 0.00 0.00 0 0 8852.45
## 5 0 0.00 0.00 0.00 0 0 0.00
## 6 0 0.00 0.00 0.00 0 0 0.00
## deudas balance otras_erog smg
## 1 0 0 0 6573.6
## 2 0 0 0 6573.6
## 3 0 0 0 6573.6
## 4 0 0 0 6573.6
## 5 0 0 0 6573.6
## 6 0 0 0 6573.6
También con “tail”, vemos las últimas 6 líneas de la base de datos
tail(enigh_concentrado)
## folioviv foliohog ubica_geo ageb tam_loc est_socio est_dis
## 70306 3260801323 1 320580001 002-A 4 2 536
## 70307 3260801324 1 320580001 007-2 4 2 536
## 70308 3260801902 1 320580001 002-A 4 2 536
## 70309 3260801904 1 320580001 002-A 4 2 536
## 70310 3260801905 1 320580001 002-A 4 2 536
## 70311 3260801906 1 320580001 002-A 4 2 536
## upm factor clase_hog sexo_jefe edad_jefe educa_jefe tot_integ
## 70306 0079010 198 1 1 60 08 1
## 70307 0079010 198 3 1 49 03 4
## 70308 0079010 198 1 2 74 01 1
## 70309 0079010 198 1 1 77 03 1
## 70310 0079010 198 2 1 67 09 3
## 70311 0079010 198 3 1 62 05 5
## hombres mujeres mayores menores p12_64 p65mas ocupados percep_ing
## 70306 1 0 1 0 1 0 1 1
## 70307 2 2 3 1 3 0 2 3
## 70308 0 1 1 0 0 1 0 1
## 70309 1 0 1 0 0 1 1 1
## 70310 1 2 2 1 1 1 0 1
## 70311 2 3 4 1 4 0 3 3
## perc_ocupa ing_cor ingtrab trabajo sueldos horas_extr comisiones
## 70306 1 28169.64 22025.54 0.00 0.00 0 0
## 70307 2 24940.72 17877.70 17877.70 17804.34 0 0
## 70308 0 19814.80 0.00 0.00 0.00 0 0
## 70309 1 23160.72 5135.86 0.00 0.00 0 0
## 70310 0 23385.60 0.00 0.00 0.00 0 0
## 70311 3 15888.51 11533.68 7522.82 7522.82 0 0
## aguinaldo indemtrab otra_rem remu_espec negocio noagrop industria
## 70306 0.00 0 0 0 22025.54 0 0
## 70307 73.36 0 0 0 0.00 0 0
## 70308 0.00 0 0 0 0.00 0 0
## 70309 0.00 0 0 0 5135.86 0 0
## 70310 0.00 0 0 0 0.00 0 0
## 70311 0.00 0 0 0 0.00 0 0
## comercio servicios agrope agricolas pecuarios reproducc pesca
## 70306 0 0 22025.54 0 22025.54 0 0
## 70307 0 0 0.00 0 0.00 0 0
## 70308 0 0 0.00 0 0.00 0 0
## 70309 0 0 5135.86 0 5135.86 0 0
## 70310 0 0 0.00 0 0.00 0 0
## 70311 0 0 0.00 0 0.00 0 0
## otros_trab rentas utilidad arrenda transfer jubilacion becas
## 70306 0.00 0 0 0 4402.17 0.00 0
## 70307 0.00 0 0 0 1256.57 0.00 0
## 70308 0.00 0 0 0 14008.35 0.00 0
## 70309 0.00 0 0 0 14540.99 0.00 0
## 70310 0.00 0 0 0 21933.99 17608.69 0
## 70311 4010.86 0 0 0 0.00 0.00 0
## donativos remesas bene_gob transf_hog trans_inst estim_alqu
## 70306 0 4402.17 0.00 0.00 0.00 1741.93
## 70307 0 0.00 1164.12 0.00 92.45 5806.45
## 70308 0 10565.21 1614.13 1829.01 0.00 5806.45
## 70309 0 0.00 4636.95 9904.04 0.00 3483.87
## 70310 0 0.00 1614.13 1928.57 782.60 1451.61
## 70311 0 0.00 0.00 0.00 0.00 4354.83
## otros_ing gasto_mon alimentos ali_dentro cereales carnes pescado
## 70306 0 8174.19 5258.41 5155.56 732.82 771.42 0
## 70307 0 18564.33 12085.51 12085.51 3227.08 1735.70 0
## 70308 0 4371.23 1934.95 1934.95 1002.82 0.00 0
## 70309 0 4102.37 1259.96 1259.96 707.12 0.00 0
## 70310 0 28360.73 6454.20 6454.20 1671.41 899.99 0
## 70311 0 12278.79 5965.66 5322.81 1928.55 1928.57 0
## leche huevo aceites tuberculo verduras frutas azucar cafe
## 70306 1774.25 0.00 0.00 404.99 642.84 565.69 0.00 0.00
## 70307 1864.25 578.56 1234.26 257.14 1349.98 0.00 128.57 154.28
## 70308 0.00 83.57 0.00 0.00 552.85 0.00 0.00 0.00
## 70309 167.14 0.00 0.00 0.00 0.00 0.00 0.00 0.00
## 70310 1002.84 668.57 0.00 231.42 1041.41 0.00 0.00 0.00
## 70311 334.28 0.00 0.00 154.28 359.99 0.00 0.00 0.00
## especias otros_alim bebidas ali_fuera tabaco vesti_calz vestido
## 70306 44.99 128.57 89.99 102.85 0 586.94 0.00
## 70307 912.84 0.00 642.85 0.00 0 0.00 0.00
## 70308 0.00 0.00 295.71 0.00 0 0.00 0.00
## 70309 0.00 0.00 385.70 0.00 0 616.29 224.99
## 70310 0.00 0.00 938.56 0.00 0 0.00 0.00
## 70311 0.00 0.00 617.14 642.85 0 313.04 117.39
## calzado vivienda alquiler pred_cons agua energia limpieza cuidados
## 70306 586.94 672.00 0 450 69 153.00 223.50 223.50
## 70307 0.00 416.08 0 0 180 236.08 1982.85 1982.85
## 70308 0.00 870.96 0 0 0 870.96 0.00 0.00
## 70309 391.30 975.64 0 50 0 925.64 89.98 89.98
## 70310 0.00 905.32 0 75 210 620.32 5548.09 412.23
## 70311 195.65 1395.96 0 0 300 1095.96 307.71 307.71
## utensilios enseres salud atenc_ambu hospital medicinas transporte
## 70306 0 0.00 880.43 391.30 0 489.13 454.21
## 70307 0 0.00 44.02 44.02 0 0.00 580.64
## 70308 0 0.00 1467.38 1467.38 0 0.00 0.00
## 70309 0 0.00 919.55 919.55 0 0.00 0.00
## 70310 0 5135.86 518.47 518.47 0 0.00 5681.05
## 70311 0 0.00 195.65 195.65 0 0.00 2651.61
## publico foraneo adqui_vehi mantenim refaccion combus comunica
## 70306 385.71 0.00 0 0.00 0.00 0.00 68.50
## 70307 0.00 0.00 0 0.00 0.00 0.00 580.64
## 70308 0.00 0.00 0 0.00 0.00 0.00 0.00
## 70309 0.00 0.00 0 0.00 0.00 0.00 0.00
## 70310 0.00 2445.65 0 2035.40 293.47 1741.93 1200.00
## 70311 0.00 0.00 0 1451.61 0.00 1451.61 1200.00
## educa_espa educacion esparci paq_turist personales cuida_pers
## 70306 0.00 0.00 0.00 0.00 98.70 98.70
## 70307 1716.28 580.64 1135.64 0.00 1738.95 1738.95
## 70308 0.00 0.00 0.00 0.00 97.94 78.38
## 70309 0.00 0.00 0.00 0.00 240.95 240.95
## 70310 8469.43 2044.87 555.00 5869.56 784.17 534.17
## 70311 555.00 0.00 555.00 0.00 894.16 894.16
## acces_pers otros_gas transf_gas percep_tot retiro_inv prestamos
## 70306 0.00 0 0 321.42 0.00 0.00
## 70307 0.00 0 0 978.26 978.26 0.00
## 70308 19.56 0 0 526.70 0.00 0.00
## 70309 0.00 0 0 0.00 0.00 0.00
## 70310 0.00 250 0 1542.85 0.00 0.00
## 70311 0.00 0 0 2005.42 0.00 2005.42
## otras_perc ero_nm_viv ero_nm_hog erogac_tot cuota_viv mater_serv
## 70306 0 0 321.42 15116.07 0 201.51
## 70307 0 0 0.00 0.00 0 0.00
## 70308 0 0 526.70 0.00 0 0.00
## 70309 0 0 0.00 3031.63 0 0.00
## 70310 0 0 1542.85 978.26 0 0.00
## 70311 0 0 0.00 1132.82 0 0.00
## material servicio deposito prest_terc pago_tarje deudas balance
## 70306 103.69 97.82 0 0 0.00 0 14914.56
## 70307 0.00 0.00 0 0 0.00 0 0.00
## 70308 0.00 0.00 0 0 0.00 0 0.00
## 70309 0.00 0.00 0 0 0.00 0 3031.63
## 70310 0.00 0.00 0 0 978.26 0 0.00
## 70311 0.00 0.00 0 0 0.00 0 1132.82
## otras_erog smg
## 70306 0 6573.6
## 70307 0 6573.6
## 70308 0 6573.6
## 70309 0 6573.6
## 70310 0 6573.6
## 70311 0 6573.6
Ver los nombres de las variables
names(enigh_concentrado)
## [1] "folioviv" "foliohog" "ubica_geo" "ageb" "tam_loc"
## [6] "est_socio" "est_dis" "upm" "factor" "clase_hog"
## [11] "sexo_jefe" "edad_jefe" "educa_jefe" "tot_integ" "hombres"
## [16] "mujeres" "mayores" "menores" "p12_64" "p65mas"
## [21] "ocupados" "percep_ing" "perc_ocupa" "ing_cor" "ingtrab"
## [26] "trabajo" "sueldos" "horas_extr" "comisiones" "aguinaldo"
## [31] "indemtrab" "otra_rem" "remu_espec" "negocio" "noagrop"
## [36] "industria" "comercio" "servicios" "agrope" "agricolas"
## [41] "pecuarios" "reproducc" "pesca" "otros_trab" "rentas"
## [46] "utilidad" "arrenda" "transfer" "jubilacion" "becas"
## [51] "donativos" "remesas" "bene_gob" "transf_hog" "trans_inst"
## [56] "estim_alqu" "otros_ing" "gasto_mon" "alimentos" "ali_dentro"
## [61] "cereales" "carnes" "pescado" "leche" "huevo"
## [66] "aceites" "tuberculo" "verduras" "frutas" "azucar"
## [71] "cafe" "especias" "otros_alim" "bebidas" "ali_fuera"
## [76] "tabaco" "vesti_calz" "vestido" "calzado" "vivienda"
## [81] "alquiler" "pred_cons" "agua" "energia" "limpieza"
## [86] "cuidados" "utensilios" "enseres" "salud" "atenc_ambu"
## [91] "hospital" "medicinas" "transporte" "publico" "foraneo"
## [96] "adqui_vehi" "mantenim" "refaccion" "combus" "comunica"
## [101] "educa_espa" "educacion" "esparci" "paq_turist" "personales"
## [106] "cuida_pers" "acces_pers" "otros_gas" "transf_gas" "percep_tot"
## [111] "retiro_inv" "prestamos" "otras_perc" "ero_nm_viv" "ero_nm_hog"
## [116] "erogac_tot" "cuota_viv" "mater_serv" "material" "servicio"
## [121] "deposito" "prest_terc" "pago_tarje" "deudas" "balance"
## [126] "otras_erog" "smg"
Revisar la estructura de la base de datos
str(enigh_concentrado)
## 'data.frame': 70311 obs. of 127 variables:
## $ folioviv : Factor w/ 69169 levels "0100003801","0100003802",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ foliohog : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ ubica_geo : Factor w/ 3103 levels "010010001","010010102",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ ageb : Factor w/ 3464 levels "001-0","001-1",..: 245 245 245 245 245 303 303 303 303 303 ...
## $ tam_loc : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 1 1 1 1 ...
## $ est_socio : Factor w/ 4 levels "1","2","3","4": 4 4 4 4 4 4 4 4 4 4 ...
## $ est_dis : Factor w/ 536 levels "001","002","003",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ upm : Factor w/ 7891 levels "0000010","0000020",..: 1 1 1 1 1 2 2 2 2 2 ...
## $ factor : int 247 247 247 247 247 200 200 200 200 200 ...
## $ clase_hog : Factor w/ 5 levels "1","2","3","4",..: 2 2 2 3 2 3 2 2 1 2 ...
## $ sexo_jefe : Factor w/ 2 levels "1","2": 1 1 1 2 1 1 2 1 2 1 ...
## $ edad_jefe : int 33 29 47 29 55 66 74 83 62 53 ...
## $ educa_jefe: Factor w/ 11 levels "01","02","03",..: 10 10 10 11 10 10 11 10 8 10 ...
## $ tot_integ : int 2 2 6 3 2 5 2 2 1 4 ...
## $ hombres : int 1 1 2 0 2 2 1 1 0 2 ...
## $ mujeres : int 1 1 4 3 0 3 1 1 1 2 ...
## $ mayores : int 2 2 3 3 2 4 2 2 1 4 ...
## $ menores : int 0 0 3 0 0 1 0 0 0 0 ...
## $ p12_64 : int 2 2 3 3 2 2 0 0 1 4 ...
## $ p65mas : int 0 0 0 0 0 2 2 2 0 0 ...
## $ ocupados : int 2 2 1 2 1 4 0 0 0 2 ...
## $ percep_ing: int 2 2 1 3 1 4 1 1 1 2 ...
## $ perc_ocupa: int 2 2 1 2 1 4 0 0 0 2 ...
## $ ing_cor : num 100697 146616 94623 58279 57295 ...
## $ ingtrab : num 100697 144157 82623 34672 42295 ...
## $ trabajo : num 100697 144157 82623 34672 42295 ...
## $ sueldos : num 97377 91475 82623 33443 35410 ...
## $ horas_extr: num 0 0 0 0 0 0 0 0 0 0 ...
## $ comisiones: num 0 0 0 0 0 0 0 0 0 0 ...
## $ aguinaldo : num 3320 10820 0 1230 6885 ...
## $ indemtrab : num 0 0 0 0 0 0 0 0 0 0 ...
## $ otra_rem : num 0 7623 0 0 0 ...
## $ remu_espec: num 0 34239 0 0 0 ...
## $ negocio : num 0 0 0 0 0 0 0 0 0 0 ...
## $ noagrop : num 0 0 0 0 0 0 0 0 0 0 ...
## $ industria : num 0 0 0 0 0 0 0 0 0 0 ...
## $ comercio : num 0 0 0 0 0 0 0 0 0 0 ...
## $ servicios : num 0 0 0 0 0 0 0 0 0 0 ...
## $ agrope : num 0 0 0 0 0 0 0 0 0 0 ...
## $ agricolas : num 0 0 0 0 0 0 0 0 0 0 ...
## $ pecuarios : num 0 0 0 0 0 0 0 0 0 0 ...
## $ reproducc : num 0 0 0 0 0 0 0 0 0 0 ...
## $ pesca : num 0 0 0 0 0 0 0 0 0 0 ...
## $ otros_trab: num 0 0 0 0 0 0 0 0 0 0 ...
## $ rentas : num 0 0 0 0 0 0 0 0 0 0 ...
## $ utilidad : num 0 0 0 0 0 0 0 0 0 0 ...
## $ arrenda : num 0 0 0 0 0 0 0 0 0 0 ...
## $ transfer : num 0 2459 0 23607 0 ...
## $ jubilacion: num 0 0 0 0 0 ...
## $ becas : num 0 0 0 0 0 0 0 0 0 0 ...
## $ donativos : num 0 2459 0 23607 0 ...
## $ remesas : num 0 0 0 0 0 0 0 0 0 0 ...
## $ bene_gob : num 0 0 0 0 0 ...
## $ transf_hog: num 0 0 0 0 0 ...
## $ trans_inst: num 0 0 0 0 0 ...
## $ estim_alqu: num 0 0 12000 0 15000 ...
## $ otros_ing : num 0 0 0 0 0 0 0 0 0 0 ...
## $ gasto_mon : num 46600 82428 54793 42452 47589 ...
## $ alimentos : num 10622 14638 21214 14567 16097 ...
## $ ali_dentro: num 9953 6281 13114 9938 10697 ...
## $ cereales : num 1764 945 1877 1286 1093 ...
## $ carnes : num 1920 579 2803 270 990 ...
## $ pescado : num 0 0 0 2571 0 ...
## $ leche : num 1130 951 3381 900 0 ...
## $ huevo : num 0 675 244 630 0 ...
## $ aceites : num 0 0 334 0 0 ...
## $ tuberculo : num 0 0 193 0 0 ...
## $ verduras : num 154 180 1466 411 0 ...
## $ frutas : num 489 0 1466 0 0 ...
## $ azucar : num 450 0 0 0 0 ...
## $ cafe : num 0 0 0 0 0 ...
## $ especias : num 1013 0 0 0 0 ...
## $ otros_alim: num 1580 2775 514 3471 6249 ...
## $ bebidas : num 1453 176 836 399 2366 ...
## $ ali_fuera : num 669 8357 8100 4629 5400 ...
## $ tabaco : num 0 0 0 0 0 0 0 0 0 0 ...
## $ vesti_calz: num 1888 9416 3463 783 1174 ...
## $ vestido : num 1888 5674 2387 0 1174 ...
## $ calzado : num 0 3742 1076 783 0 ...
## $ vivienda : num 10544 9526 930 15825 3155 ...
## $ alquiler : num 8100 9000 0 12000 0 0 0 0 0 0 ...
## $ pred_cons : num 450 0 0 0 125 150 87.5 100 200 190 ...
## $ agua : num 750 291 630 600 585 ...
## $ energia : num 1244 236 300 3225 2445 ...
## $ limpieza : num 15343 8407 9278 1905 6483 ...
## $ cuidados : num 1425 1524 1206 1905 5802 ...
## $ utensilios: num 0 342 695 0 235 ...
## $ enseres : num 13918 6541 7377 0 447 ...
## $ salud : num 983 4397 1448 685 0 ...
## $ atenc_ambu: num 983 1590 0 685 0 ...
## $ hospital : num 0 2808 0 0 0 ...
## $ medicinas : num 0 0 1448 0 0 ...
## $ transporte: num 3450 10367 13050 6420 2940 ...
## $ publico : num 0 0 0 0 0 ...
## $ foraneo : num 0 2754 0 0 0 ...
## $ adqui_vehi: num 0 0 0 0 0 0 0 0 0 0 ...
## $ mantenim : num 2100 5363 9000 1800 1440 ...
## $ refaccion : num 0 2213 0 0 0 ...
## $ combus : num 2100 3150 9000 1800 1440 ...
## [list output truncated]
## - attr(*, "data_types")= chr "C" "C" "C" "C" ...
Otro comando que hace algo similar, en el universo tidy, tydiverse https://www.tidyverse.org/, con la librería dplyr y el comando glimpse
install.packages("dplyr", repos = "http://cran.us.r-project.org", dependencies = TRUE)
## Installing package into '/Users/anaescoto/Library/R/3.3/library'
## (as 'lib' is unspecified)
## also installing the dependencies 'processx', 'bindrcpp', 'Rcpp', 'rlang', 'callr', 'mgcv', 'microbenchmark'
##
## There are binary versions available but the source versions are
## later:
## binary source needs_compilation
## processx 2.0.0.1 3.1.0 TRUE
## bindrcpp 0.2 0.2.2 TRUE
## Rcpp 0.12.14 0.12.17 TRUE
## rlang 0.1.6 0.2.1 TRUE
## callr 1.0.0 2.0.4 FALSE
## mgcv 1.8-22 1.8-24 TRUE
## microbenchmark 1.4-3 1.4-4 TRUE
## dplyr 0.7.4 0.7.6 TRUE
## installing the source packages 'processx', 'bindrcpp', 'Rcpp', 'rlang', 'callr', 'mgcv', 'microbenchmark', 'dplyr'
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'processx' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'Rcpp' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'rlang' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'mgcv' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'microbenchmark' had non-zero exit
## status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'bindrcpp' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'callr' had non-zero exit status
## Warning in install.packages("dplyr", repos = "http://cran.us.r-
## project.org", : installation of package 'dplyr' had non-zero exit status
library(dplyr)
##
## 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
glimpse(enigh_concentrado)
## Observations: 70,311
## Variables: 127
## $ folioviv <fctr> 0100003801, 0100003802, 0100003803, 0100003804, 01...
## $ foliohog <fctr> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ ubica_geo <fctr> 010010001, 010010001, 010010001, 010010001, 010010...
## $ ageb <fctr> 023-3, 023-3, 023-3, 023-3, 023-3, 028-6, 028-6, 0...
## $ tam_loc <fctr> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ est_socio <fctr> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,...
## $ est_dis <fctr> 003, 003, 003, 003, 003, 003, 003, 003, 003, 003, ...
## $ upm <fctr> 0000010, 0000010, 0000010, 0000010, 0000010, 00000...
## $ factor <int> 247, 247, 247, 247, 247, 200, 200, 200, 200, 200, 2...
## $ clase_hog <fctr> 2, 2, 2, 3, 2, 3, 2, 2, 1, 2, 2, 3, 2, 2, 3, 1, 2,...
## $ sexo_jefe <fctr> 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1,...
## $ edad_jefe <int> 33, 29, 47, 29, 55, 66, 74, 83, 62, 53, 50, 69, 82,...
## $ educa_jefe <fctr> 10, 10, 10, 11, 10, 10, 11, 10, 08, 10, 10, 04, 03...
## $ tot_integ <int> 2, 2, 6, 3, 2, 5, 2, 2, 1, 4, 3, 5, 2, 4, 9, 1, 4, ...
## $ hombres <int> 1, 1, 2, 0, 2, 2, 1, 1, 0, 2, 1, 1, 0, 2, 4, 1, 3, ...
## $ mujeres <int> 1, 1, 4, 3, 0, 3, 1, 1, 1, 2, 2, 4, 2, 2, 5, 0, 1, ...
## $ mayores <int> 2, 2, 3, 3, 2, 4, 2, 2, 1, 4, 3, 3, 2, 4, 6, 1, 4, ...
## $ menores <int> 0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 3, 0, 0, ...
## $ p12_64 <int> 2, 2, 3, 3, 2, 2, 0, 0, 1, 4, 3, 1, 1, 4, 6, 0, 4, ...
## $ p65mas <int> 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 1, 0, 0, 1, 0, ...
## $ ocupados <int> 2, 2, 1, 2, 1, 4, 0, 0, 0, 2, 3, 3, 0, 2, 5, 0, 3, ...
## $ percep_ing <int> 2, 2, 1, 3, 1, 4, 1, 1, 1, 2, 3, 3, 2, 4, 5, 1, 3, ...
## $ perc_ocupa <int> 2, 2, 1, 2, 1, 4, 0, 0, 0, 2, 3, 3, 0, 2, 5, 0, 3, ...
## $ ing_cor <dbl> 100696.70, 146616.16, 94622.95, 58278.65, 57295.07,...
## $ ingtrab <dbl> 100696.70, 144157.15, 82622.95, 34672.11, 42295.07,...
## $ trabajo <dbl> 100696.70, 144157.15, 82622.95, 34672.11, 42295.07,...
## $ sueldos <dbl> 97377.04, 91475.40, 82622.95, 33442.61, 35409.83, 2...
## $ horas_extr <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ comisiones <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ aguinaldo <dbl> 3319.66, 10819.67, 0.00, 1229.50, 6885.24, 3546.19,...
## $ indemtrab <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ otra_rem <dbl> 0.00, 7622.95, 0.00, 0.00, 0.00, 733.69, 0.00, 0.00...
## $ remu_espec <dbl> 0.00, 34239.13, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,...
## $ negocio <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ noagrop <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ industria <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ comercio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ servicios <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ agrope <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ agricolas <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ pecuarios <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ reproducc <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ pesca <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ otros_trab <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ rentas <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ utilidad <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ arrenda <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ transfer <dbl> 0.00, 2459.01, 0.00, 23606.54, 0.00, 104052.19, 222...
## $ jubilacion <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 82173.90, 14673.91, 1...
## $ becas <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ donativos <dbl> 0.00, 2459.01, 0.00, 23606.54, 0.00, 0.00, 0.00, 0....
## $ remesas <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ bene_gob <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 3326.08, 0.00, 0.00, ...
## $ transf_hog <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 489.12, 6380.31, 1285...
## $ trans_inst <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 18063.09, 1173.90, 12...
## $ estim_alqu <dbl> 0.00, 0.00, 12000.00, 0.00, 15000.00, 14516.12, 116...
## $ otros_ing <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ gasto_mon <dbl> 46599.96, 82427.75, 54792.51, 42452.37, 47589.29, 3...
## $ alimentos <dbl> 10621.89, 14637.70, 21214.07, 14567.00, 16097.03, 1...
## $ ali_dentro <dbl> 9953.32, 6280.59, 13114.08, 9938.43, 10697.04, 1109...
## $ cereales <dbl> 1763.94, 944.97, 1877.10, 1285.67, 1092.83, 1645.66...
## $ carnes <dbl> 1920.33, 578.57, 2802.85, 269.99, 989.99, 3355.66, ...
## $ pescado <dbl> 0.00, 0.00, 0.00, 2571.42, 0.00, 0.00, 719.99, 0.00...
## $ leche <dbl> 1130.13, 951.40, 3381.40, 899.99, 0.00, 2712.79, 14...
## $ huevo <dbl> 0.00, 674.99, 244.28, 629.99, 0.00, 539.99, 372.85,...
## $ aceites <dbl> 0.00, 0.00, 334.28, 0.00, 0.00, 0.00, 0.00, 0.00, 0...
## $ tuberculo <dbl> 0.00, 0.00, 192.85, 0.00, 0.00, 0.00, 0.00, 154.28,...
## $ verduras <dbl> 154.28, 179.98, 1465.66, 411.41, 0.00, 192.85, 610....
## $ frutas <dbl> 488.56, 0.00, 1465.68, 0.00, 0.00, 938.54, 2134.26,...
## $ azucar <dbl> 449.99, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0...
## $ cafe <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ especias <dbl> 1013.13, 0.00, 0.00, 0.00, 0.00, 231.42, 0.00, 0.00...
## $ otros_alim <dbl> 1580.13, 2774.54, 514.28, 3471.40, 6248.54, 1478.56...
## $ bebidas <dbl> 1452.83, 176.14, 835.70, 398.56, 2365.68, 0.00, 231...
## $ ali_fuera <dbl> 668.57, 8357.11, 8099.99, 4628.57, 5399.99, 3085.70...
## $ tabaco <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ vesti_calz <dbl> 1888.03, 9415.70, 3463.01, 782.60, 1173.90, 0.00, 0...
## $ vestido <dbl> 1888.03, 5673.88, 2386.93, 0.00, 1173.90, 0.00, 0.0...
## $ calzado <dbl> 0.00, 3741.82, 1076.08, 782.60, 0.00, 0.00, 0.00, 0...
## $ vivienda <dbl> 10543.50, 9526.50, 930.00, 15825.00, 3155.00, 3193....
## $ alquiler <dbl> 8100.00, 9000.00, 0.00, 12000.00, 0.00, 0.00, 0.00,...
## $ pred_cons <dbl> 450.00, 0.00, 0.00, 0.00, 125.00, 150.00, 87.50, 10...
## $ agua <dbl> 750.00, 291.00, 630.00, 600.00, 585.00, 943.54, 900...
## $ energia <dbl> 1243.50, 235.50, 300.00, 3225.00, 2445.00, 2100.00,...
## $ limpieza <dbl> 15343.01, 8407.35, 9277.60, 1905.00, 6483.33, 1729....
## $ cuidados <dbl> 1425.00, 1524.00, 1206.00, 1905.00, 5802.00, 1695.4...
## $ utensilios <dbl> 0.00, 342.39, 694.56, 0.00, 234.78, 0.00, 0.00, 0.0...
## $ enseres <dbl> 13918.01, 6540.96, 7377.04, 0.00, 446.55, 34.23, 0....
## $ salud <dbl> 983.13, 4397.26, 1447.82, 684.77, 0.00, 0.00, 0.00,...
## $ atenc_ambu <dbl> 983.13, 1589.66, 0.00, 684.77, 0.00, 0.00, 0.00, 0....
## $ hospital <dbl> 0.00, 2807.60, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ medicinas <dbl> 0.00, 0.00, 1447.82, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ transporte <dbl> 3450.00, 10367.19, 13050.00, 6420.00, 2940.00, 1172...
## $ publico <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ foraneo <dbl> 0.00, 2754.08, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ adqui_vehi <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ mantenim <dbl> 2100.00, 5363.11, 9000.00, 1800.00, 1440.00, 9290.3...
## $ refaccion <dbl> 0.00, 2213.11, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ combus <dbl> 2100.00, 3150.00, 9000.00, 1800.00, 1440.00, 9290.3...
## $ comunica <dbl> 1350.00, 2250.00, 4050.00, 4620.00, 1500.00, 2432.8...
## $ educa_espa <dbl> 900.00, 2213.11, 600.00, 450.00, 9267.00, 2045.52, ...
## $ educacion <dbl> 0.00, 0.00, 0.00, 0.00, 5067.00, 1115.52, 0.00, 0.0...
## $ esparci <dbl> 900.00, 2213.11, 600.00, 450.00, 4200.00, 930.00, 3...
## $ paq_turist <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ personales <dbl> 2870.40, 18472.01, 4810.01, 1818.00, 8473.03, 2887....
## $ cuida_pers <dbl> 1395.00, 15303.00, 1101.00, 1818.00, 3555.00, 2412....
## $ acces_pers <dbl> 0.00, 3081.51, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ otros_gas <dbl> 1475.40, 87.50, 3709.01, 0.00, 4918.03, 475.00, 0.0...
## $ transf_gas <dbl> 0.00, 4990.93, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ percep_tot <dbl> 0.00, 880.43, 0.00, 0.00, 0.00, 8559.77, 391.30, 12...
## $ retiro_inv <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ prestamos <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ otras_perc <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 8559.77, 0.00, 0.00, ...
## $ ero_nm_viv <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ ero_nm_hog <dbl> 0.00, 880.43, 0.00, 0.00, 0.00, 0.00, 391.30, 1285....
## $ erogac_tot <dbl> 17508.19, 5360.65, 23778.68, 8852.45, 0.00, 0.00, 0...
## $ cuota_viv <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ mater_serv <dbl> 98.36, 0.00, 172.13, 0.00, 0.00, 0.00, 0.00, 0.00, ...
## $ material <dbl> 98.36, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 19...
## $ servicio <dbl> 0.00, 0.00, 172.13, 0.00, 0.00, 0.00, 0.00, 0.00, 1...
## $ deposito <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ prest_terc <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ pago_tarje <dbl> 17409.83, 5360.65, 23606.55, 8852.45, 0.00, 0.00, 0...
## $ deudas <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0...
## $ balance <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ otras_erog <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 176...
## $ smg <dbl> 6573.6, 6573.6, 6573.6, 6573.6, 6573.6, 6573.6, 657...
Si queremos ver los niveles de una variable, tenemos que usar el formato basedatos$var. Esto nos llevará a la variable dentro del objeto que tenemos que es una base de datos. Esto nos permite tener varias bases de datos cargadas en un mismo ambiente.
levels(enigh_concentrado$sexo_jefe)
## [1] "1" "2"
También podemos pedir una tabla de una variable.
table(enigh_concentrado$sexo_jefe)
##
## 1 2
## 51918 18393
table(enigh_concentrado$edad)
##
## 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
## 1 3 10 46 108 174 307 371 474 601 718 777 887 952 1043
## 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
## 1075 1340 1151 1362 1400 1436 1390 1616 1511 1770 1606 1826 1470 1930 1798
## 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
## 1559 1696 1650 1505 1668 1376 1692 1252 1549 1375 1367 1276 1465 1122 1239
## 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
## 1130 1355 880 1007 1099 993 1060 954 842 763 701 809 544 708 636
## 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
## 624 582 590 463 434 336 442 281 302 293 276 234 239 160 131
## 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
## 102 98 69 59 33 40 24 27 11 10 9 4 3 1 2
## 104 105
## 2 5
Para ver las dimensiones de cualquier objeto, en este caso nos dirá el número de observaciones y variables
dim(enigh_concentrado)
## [1] 70311 127
Si queremos saber el tipo o clase de un objeto (numeric, matrix, data frame, etc)
class(enigh_concentrado)
## [1] "data.frame"