library(ggplot2)
## Carga de datos (supongamos que el conjunto de datos se llama "educacion_inegi.csv")
## Establecer el directorio de trabajo
#setwd("~/Documentos/cursoR_UNADM/")
## Cargar el archivo y cambiar el nombre
datos <- read.csv("educacion_inegi.csv")
## Crear un subset con las columnas necesarias
datos_filtrados <- subset(datos, select = c(FOLIO, EDAD, PB3_12_1, PB3_12_2, PB3_14, ESC))
## Renombrar las columnas
names(datos_filtrados) <- c("id", "edad", "uso_smartphone", "uso_laptop_o_notebook", "horas_dedicadas_familiar", "escolaridad_alcanzada")
## Visualizar las primeras filas del nuevo dataframe
summary(datos_filtrados)
## id edad uso_smartphone uso_laptop_o_notebook
## Min. : 2 Min. : 0.00 Min. :1.000 Min. :1.000
## 1st Qu.: 5788 1st Qu.: 8.00 1st Qu.:1.000 1st Qu.:1.000
## Median :11462 Median :15.00 Median :1.000 Median :2.000
## Mean :11452 Mean :14.89 Mean :1.273 Mean :1.668
## 3rd Qu.:17127 3rd Qu.:21.00 3rd Qu.:2.000 3rd Qu.:2.000
## Max. :22718 Max. :29.00 Max. :2.000 Max. :2.000
## NA's :12704 NA's :12704
## horas_dedicadas_familiar escolaridad_alcanzada
## Min. : 0.000 Min. :0.000
## 1st Qu.: 4.000 1st Qu.:2.000
## Median : 5.000 Median :3.000
## Mean : 7.336 Mean :3.033
## 3rd Qu.:10.000 3rd Qu.:4.000
## Max. :99.000 Max. :6.000
## NA's :20038 NA's :2055
## Warning: Removed 2055 rows containing non-finite outside the scale range
## (`stat_count()`).
## Warning: Removed 20038 rows containing missing values or values outside the scale range
## (`geom_point()`).
El parámetro ‘echo = FALSE’ se agregó al bloque de código para evitar la impresión del código R que generó la gráfica.
##
## Pearson's product-moment correlation
##
## data: datos_filtrados$edad and datos_filtrados$horas_dedicadas_familiar
## t = -14.96, df = 12303, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.1509769 -0.1162698
## sample estimates:
## cor
## -0.1336643
##
## Pearson's product-moment correlation
##
## data: datos_filtrados$uso_smartphone and datos_filtrados$uso_laptop_o_notebook
## t = 4.6533, df = 19637, p-value = 3.288e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.01921100 0.04715217
## sample estimates:
## cor
## 0.03318807
## Df Sum Sq Mean Sq F value Pr(>F)
## escolaridad_alcanzada 1 4249 4249 124.2 <2e-16 ***
## Residuals 12303 420807 34
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 20038 observations deleted due to missingness
##
## 1 2
## 1 4884 9400
## 2 1643 3712
## Warning: Removed 12704 rows containing non-finite outside the scale range
## (`stat_count()`).
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?