install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── 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
install.packages("summarytools")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(summarytools)
## Warning in fun(libname, pkgname): couldn't connect to display ":0"
## system might not have X11 capabilities; in case of errors when using dfSummary(), set st_options(use.x11 = FALSE)
## 
## Attaching package: 'summarytools'
## The following object is masked from 'package:tibble':
## 
##     view
install.packages("readxl")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(readxl)
datos <- read_excel("Encuesta.ing.xlsx")
ggplot()

descr(datos$EDAD)
## Descriptive Statistics  
## datos$EDAD  
## N: 42  
## 
##                       EDAD
## ----------------- --------
##              Mean    19.71
##           Std.Dev     2.43
##               Min    17.00
##                Q1    18.00
##            Median    19.00
##                Q3    21.00
##               Max    28.00
##               MAD     1.48
##               IQR     3.00
##                CV     0.12
##          Skewness     1.49
##       SE.Skewness     0.37
##          Kurtosis     1.81
##           N.Valid    42.00
##                 N    42.00
##         Pct.Valid   100.00
ggplot(datos, aes(x = EDAD, y = "")) +
  geom_boxplot(fill = "steelblue", width = 0.3, outlier.color = "red", outlier.shape = 16) +
  coord_cartesian(xlim = c(17, 30)) +
  scale_x_continuous(breaks = seq(17, 30, by = 2)) +
  labs(title = "Distribución de la variable Edad",
       x = "Edad",
       y = "") +
  theme_minimal(base_size = 13) +
  theme(
    axis.line = element_line(color = "black"),
    panel.grid.major.y = element_blank(),
    panel.grid.minor = element_blank(),
    axis.ticks = element_line(color = "black"),
    plot.title = element_text(face = "bold")
  )

#tabla de frecuencia para Genero 
freq(datos$GENERO)
## Frequencies  
## datos$GENERO  
## Type: Character  
## 
##                   Freq   % Valid   % Valid Cum.   % Total   % Total Cum.
## --------------- ------ --------- -------------- --------- --------------
##        Femenino     24     57.14          57.14     57.14          57.14
##       Masculino     18     42.86         100.00     42.86         100.00
##            <NA>      0                               0.00         100.00
##           Total     42    100.00         100.00    100.00         100.00
tabla_genero <- as.data.frame(table(datos$GENERO))
colnames(tabla_genero) <- c("Género", "Frecuencia")
tabla_genero$Porcentaje <- round((tabla_genero$Frecuencia / sum(tabla_genero$Frecuencia)) * 100, 1)
tabla_genero
##      Género Frecuencia Porcentaje
## 1  Femenino         24       57.1
## 2 Masculino         18       42.9
# Gráfico de torta con porcentajes
ggplot(tabla_genero, aes(x = "", y = Frecuencia, fill = Género)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar("y") +
  labs(title = "Distribución por Género", fill = "Género") +
  theme_void() +
  geom_text(aes(label = paste0(Porcentaje, "%")), 
            position = position_stack(vjust = 0.5), color = "white", size = 6)  

#Preguntas de caracterizacion- Lugar de procedencia 
freq(datos$PROCEDENCIA, order = "freq", round.digits = 1, report.nas = FALSE, justify = "center",  style = "simple")
## Frequencies  
## datos$PROCEDENCIA  
## Type: Character  
## 
##                              Freq     %     % Cum. 
## --------------------------- ------ ------- --------
##    Interior de Catamarca      19    45.2     45.2  
##      Catamarca capital        16    38.1     83.3  
##           Tucumán             5     11.9     95.2  
##       Otra provincia          2      4.8    100.0  
##            Total              42    100.0   100.0
#Preguntas de caracterizacion- Trabajo
freq(datos$TRABAJO, order = "freq", round.digits = 1, report.nas = FALSE, justify = "center",  style = "simple")
## Frequencies  
## datos$TRABAJO  
## Type: Character  
## 
##                                      Freq     %     % Cum. 
## ----------------------------------- ------ ------- --------
##                 No                    18    42.9     42.9  
##            Solo estudio               18    42.9     85.7  
##    Eventualmente fines de semana      4      9.5     95.2  
##                 Si                    2      4.8    100.0  
##                Total                  42    100.0   100.0
#variable nominal, herramienta utilizada para estudiar
 freq(datos$HERRAMIENTA, order = "freq", round.digits = 1, report.nas = FALSE, justify = "center",  style = "simple")
## Frequencies  
## datos$HERRAMIENTA  
## Type: Character  
## 
##                          Freq     %     % Cum. 
## ----------------------- ------ ------- --------
##    Apuntes digitales      16    38.1     38.1  
##     Libros fisicos        10    23.8     61.9  
##    Videos educativos      10    23.8     85.7  
##      Chat gpt/ IA         4      9.5     95.2  
##          Otro             2      4.8    100.0  
##          Total            42    100.0   100.0
#grafico de barras  lugar de procedencia del estudiante
ggplot(datos, aes(x = PROCEDENCIA, fill = PROCEDENCIA)) +
  geom_bar() +
  labs(title = "Procedencia de los estudiantes", 
       x = "", 
       y = "Nº de estudiantes") +
  theme_linedraw()

freq(datos$RENDIMIENTO, round.digits = 1, report.nas = FALSE, justify = "center",  style = "simple")
## Frequencies  
## datos$RENDIMIENTO  
## Type: Character  
## 
##                 Freq     %     % Cum. 
## -------------- ------ ------- --------
##      Alto        17    40.5     40.5  
##      Bajo        21    50.0     90.5  
##    Muy alto      1      2.4     92.9  
##    Muy bajo      3      7.1    100.0  
##     Total        42    100.0   100.0
metodos <- datos %>%
  group_by(METODO) %>%
  summarise(Frecuencia = n()) %>%
  mutate(Porcentaje = round(Frecuencia / sum(Frecuencia) * 100, 1))
#Variable Nominal. Metodo de estudio utilizado
ggplot(data = metodos, aes(x = "", y = Frecuencia, fill = METODO)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar("y") +
  labs(title = "Método de estudio utilizado", fill = "Método") +
  theme_void() +
  geom_text(aes(label = paste0(Porcentaje, "%")),
            position = position_stack(vjust = 0.5), color = "white", size = 4)

freq(datos$TECNICA, order = "freq", round.digits = 1, report.nas = FALSE, justify = "center",  style = "simple")
## Frequencies  
## datos$TECNICA  
## Type: Character  
## 
##                                  Freq     %     % Cum. 
## ------------------------------- ------ ------- --------
##         Hacer resúmenes           13    31.0     31.0  
##      Subrayado y resaltado        12    28.6     59.5  
##       Lectura en voz alta         6     14.3     73.8  
##         Fichas o notas            3      7.1     81.0  
##              Otra                 3      7.1     88.1  
##    Ninguna de las anteriores      2      4.8     92.9  
##      Repetición espaciada         2      4.8     97.6  
##       Mapas conceptuales          1      2.4    100.0  
##              Total                42    100.0   100.0
freq(datos$RENDIMIENTO, round.digits = 1, report.nas = FALSE, justify = "center", headings = FALSE)
## 
##                 Freq     %     % Cum. 
## -------------- ------ ------- --------
##      Alto        17    40.5     40.5  
##      Bajo        21    50.0     90.5  
##    Muy alto      1      2.4     92.9  
##    Muy bajo      3      7.1    100.0  
##     Total        42    100.0   100.0
freq(datos$SATIFACCION, round.digits = 1, report.nas = FALSE, justify= "center", headings = FALSE)
## 
##                         Freq     %     % Cum. 
## ---------------------- ------ ------- --------
##      Insatisfecho        6     14.3     14.3  
##    Muy insatisfecho      4      9.5     23.8  
##     Muy satisfecho       2      4.8     28.6  
##        Neutral           22    52.4     81.0  
##       Satisfecho         8     19.0    100.0  
##         Total            42    100.0   100.0
datos%>%
  group_by(GENERO) %>% 
  freq(SATIFACCION, report.nas = FALSE, headings = FALSE)
## Group: GENERO = Femenino  
## 
##                          Freq        %   % Cum.
## ---------------------- ------ -------- --------
##           Insatisfecho      5    20.83    20.83
##       Muy insatisfecho      2     8.33    29.17
##         Muy satisfecho      1     4.17    33.33
##                Neutral      9    37.50    70.83
##             Satisfecho      7    29.17   100.00
##                  Total     24   100.00   100.00
## 
## Group: GENERO = Masculino  
## 
##                          Freq        %   % Cum.
## ---------------------- ------ -------- --------
##           Insatisfecho      1     5.56     5.56
##       Muy insatisfecho      2    11.11    16.67
##         Muy satisfecho      1     5.56    22.22
##                Neutral     13    72.22    94.44
##             Satisfecho      1     5.56   100.00
##                  Total     18   100.00   100.00
ggplot(datos, aes(x = GENERO, fill = RENDIMIENTO)) +
  geom_bar(position = "stack") +               
  xlab("Género") +                                   # Etiqueta del eje X
  ylab("Cantidad de estudiantes") +                  # Etiqueta del eje Y
  labs(fill = "Nivel de Rendimiento") +              # Título de la leyenda
  scale_y_continuous(limits = c(0, 25))  

freq(datos$DIAS_DE_ESTUDIO,round.digits = 1, report.nas = FALSE, justify = "center", )
## Frequencies  
## datos$DIAS_DE_ESTUDIO  
## Type: Numeric  
## 
##              Freq     %     % Cum. 
## ----------- ------ ------- --------
##      0        1      2.4     2.4   
##      1        1      2.4     4.8   
##      2        4      9.5     14.3  
##      3        13    31.0     45.2  
##      4        10    23.8     69.0  
##      5        3      7.1     76.2  
##      6        6     14.3     90.5  
##      7        4      9.5    100.0  
##    Total      42    100.0   100.0
descr(datos$PARCIALES_AP,round.digits = 1, headings = FALSE)
## 
##                     PARCIALES_AP
## ----------------- --------------
##              Mean            2.3
##           Std.Dev            1.3
##               Min            0.0
##                Q1            1.0
##            Median            2.0
##                Q3            3.0
##               Max            5.0
##               MAD            1.5
##               IQR            1.8
##                CV            0.5
##          Skewness            0.0
##       SE.Skewness            0.4
##          Kurtosis           -0.4
##           N.Valid           42.0
##                 N           42.0
##         Pct.Valid          100.0
ggplot(datos, aes(x = PROCEDENCIA, y = PARCIALES_AP)) + 
  geom_boxplot(aes(fill = PROCEDENCIA)) +
  labs(title = "Parciales Aprobados por Lugar de Procedencia",
       x = "Lugar de Procedencia",
       y = "Número de Parciales Aprobados") +
  theme_minimal() +
  theme(legend.position = "none")

freq(datos$LIBRE,round.digits = 1, report.nas = FALSE, justify = "center", )
## Frequencies  
## datos$LIBRE  
## Type: Numeric  
## 
##              Freq     %     % Cum. 
## ----------- ------ ------- --------
##      0        23    54.8     54.8  
##      1        16    38.1     92.9  
##      2        2      4.8     97.6  
##      3        1      2.4    100.0  
##    Total      42    100.0   100.0
ggplot(datos, aes(x = HORAS_ESTUDIO)) +  # Cambia 'Horas_de_Estudio' por el nombre correcto de la variable
  geom_histogram(binwidth = 1, fill = "skyblue", color = "black", alpha = 0.7) +  # Definir el tamaño de los bins
  xlab("Horas de Estudio") +  # Etiqueta del eje X
  ylab("Nº estudiantes") +  # Etiqueta del eje Y
  labs(title = "Distribución de las Horas de Estudio") +  # Título del gráfico
  theme_dark() +  # Estilo minimalista
  theme(
    axis.title.x = element_text(size = 14, face = "bold"),  # Tamaño y negrita del título del eje X
    axis.title.y = element_text(size = 14, face = "bold"),  # Tamaño y negrita del título del eje Y
    axis.text.x  = element_text(size = 12, face = "bold"),  # Tamaño y negrita de los valores del eje X
    axis.text.y  = element_text(size = 12, face = "bold")   # Tamaño y negrita de los valores del eje Y
  )

ggplot(datos, aes(x = HORAS_ESTUDIO, color = GENERO)) +
  geom_freqpoly(bins = 8, size = 1) +
  scale_x_continuous(limits = c(0, 8), breaks = 0:8) +
  scale_y_continuous(limits = c(0, 12), breaks = seq(0, 12, 2)) +
  labs(
    title = "Distribución de horas de estudio según género",
    x = "Horas de estudio por día",
    y = "N° de estudiantes",
    color = "Género"
  ) +
  theme_minimal() +
  theme(
    axis.title.x = element_text(size = 14, face = "bold"),
    axis.title.y = element_text(size = 14, face = "bold"),
    axis.text.x = element_text(size = 12, face = "bold"),
    axis.text.y = element_text(size = 12, face = "bold"),
    plot.title = element_text(size = 16, face = "bold", hjust = 0.5)
  )
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_path()`).

# Rendimiento segun genero
datos %>%
  group_by(GENERO) %>% 
  freq(RENDIMIENTO, report.nas = FALSE, headings = FALSE)
## Group: GENERO = Femenino  
## 
##                  Freq        %   % Cum.
## -------------- ------ -------- --------
##           Alto     11    45.83    45.83
##           Bajo     12    50.00    95.83
##       Muy bajo      1     4.17   100.00
##          Total     24   100.00   100.00
## 
## Group: GENERO = Masculino  
## 
##                  Freq        %   % Cum.
## -------------- ------ -------- --------
##           Alto      6    33.33    33.33
##           Bajo      9    50.00    83.33
##       Muy alto      1     5.56    88.89
##       Muy bajo      2    11.11   100.00
##          Total     18   100.00   100.00
ggplot(datos, aes(x = GENERO, fill = RENDIMIENTO)) +
  geom_bar(position = "stack") +  # Usa "stack" para apilar las barras por niveles de dificultad
  xlab("Género") +  # Etiqueta del eje X
  ylab("Cantidad de estudiantes") +  # Etiqueta del eje Y
  labs(fill = "Rendimiento percibido") +  # Título de la leyenda
  scale_y_continuous(limits= c(0,30)) + # recorrido del eje y
  theme(axis.title.x = element_text(size = 14, face = "bold"),  # Tamaño y negrita ("bold") del título del eje X
    axis.title.y = element_text(size = 14, face = "bold"),  # Tamaño y negrita del título del eje Y
    axis.text.x  = element_text(size = 12, face = "bold"),  # Tamaño y negrita de los valores del eje X
    axis.text.y  = element_text(size = 12, face = "bold"),  # Tamaño y negrita de los valores del eje Y
    legend.title = element_text(size = 10, face = "bold"),  # Tamaño y negrita del título de la leyenda
    legend.text  = element_text(size = 8)  # Tamaño del texto de la leyenda
  )

ggplot(datos, aes(y = METODO, x = PARCIALES_AP)) + 
  geom_boxplot(aes(fill = METODO), position = position_dodge(width = 0.75)) +
  labs(
    title = "Relación parcial AP / Metodo",
    y = "Método",
    x = "Número de Parciales Aprobados"
  ) +
  theme_minimal() +
  theme(legend.position = "none")

ggplot(datos, aes(x = METODO, y = LIBRE, fill = METODO)) +
  geom_bar(stat = "identity", width = 0.6) +
  scale_y_continuous(limits = c(0, 15), breaks = seq(0, 12, 2)) +
  labs(
    title = " Condicion de libre segun método de estudio",
    x = "-",
    y = "Numero de materias reprobadas"
  ) +
  theme_minimal(base_size = 13) 

ggplot(datos, aes(x = TECNICA, y = PARCIALES_AP, fill = TECNICA)) +
  geom_bar(stat = "identity", width = 0.6) +
  scale_y_continuous(limits = c(0, 32), breaks = seq(0,32, 2)) +
  labs(
    title = " Parciales aprobados por tecnica de estudio",
    x = "-",
    y = "Numero de parciales aprobados"
  ) +
  theme_minimal(base_size = 13) 

datos_resumidos <- datos %>%
  group_by(SECUNDARIA) %>%
  summarise(PARCIALES_TOTAL = sum(PARCIALES_AP, na.rm = TRUE))
print(datos_resumidos)
## # A tibble: 4 × 2
##   SECUNDARIA                     PARCIALES_TOTAL
##   <chr>                                    <dbl>
## 1 Escuela Técnica                              7
## 2 Escuela agro-técnica                        24
## 3 Otro tipo                                   11
## 4 Secundaria común/ bachillerato              54
ggplot(datos, aes(x = SECUNDARIA, y = PARCIALES_AP)) +
  geom_bar(stat = "identity", fill = "#0073C2FF") +
  scale_y_continuous(limits = c(0, 60), breaks = seq(0, 60, by = 5)) +  # Escala de 0 a 60 de 2 en 2
  labs(title = "Parciales aprobados según tipo de secundaria",
       y = "Total de parciales aprobados") +
  theme_minimal()

ggplot(datos, aes(x = GENERO, y = PARCIALES_AP)) + 
  geom_boxplot(aes(fill = GENERO), position = position_dodge(width = 0.75)) +
  labs(
    title = "Relación Parciales Aprobados / Género",
    x = "Género",
    y = "Número de Parciales Aprobados"
  ) +
  theme_minimal() +
  theme(legend.position = "none")