📚 Librería
library(readxl)
library(glue)
library(dplyr)
library(psych)
library(ggplot2)
library(knitr)
library(janitor)
library(nortest)
library(kableExtra)
library(tidyr)
library(ggrepel)
📥 Importar datos
datos <- read_excel("/Users/adrianaholguin/Desktop/Copia de Tabla analisis tesis R.xlsx")
##Limpiar nombres
# Renombrar columnas
names(datos) <- c(
"Serie", "Edad", "Sexo", "Estado_civil", "Trabaja", "Residente", "Vive_con",
"Grupo_vulnerabilidad", "Tipo_familia", "Num_personas_casa", "Nivel_socioeconomico",
"Involucramiento_familiar", "Involucramiento_personal", "Gusto_voluntariado",
"Areas_interes", "Ha_voluntariado", "Cantidad_voluntariados", "Quien_involucro",
"Tipos_voluntariados", "Motivacion_voluntariado", "Percibe_beneficio",
"Beneficio_percibido", "Recuerdo_voluntariado", "Volveria_participar",
"Motivo_no_participar", "Le_gustaria_participar", "Beneficio_esperado",
# Ítems del instrumento A
"A_item1", "A_item2", "A_item3", "A_item4", "A_item5", "A_item6",
"A_item7", "A_item8", "A_item9", "A_item10", "A_item11", "A_item12",
"A_item13", "A_item14", "A_item15", "A_item16",
"Ayudar_A", "Empatia_A", "Compartir_A", "Total_A",
# Ítems del instrumento B
"B_item1", "B_item2", "B_item3", "B_item4", "B_item5", "B_item6",
"B_item7", "B_item8", "B_item9", "B_item10", "B_item11", "B_item12",
"B_item13", "B_item14", "B_item15", "B_item16",
"Ayudar_B", "Empatia_B", "Compartir_B", "Total_B"
)
❓Preguntas de investigación
``` r
pregunta_general <- "¿Qué relación existe entre la participación en un voluntariado curricular y el desarrollo de conductas prosociales en estudiantes universitarios?"
pregunta_cuantitativa <- "¿Existe una diferencia significativa en los niveles de prosocialidad de los estudiantes universitarios antes y después de participar en un voluntariado curricular, medida con la escala de prosocialidad para adultos de Caprara?"
glue("
**Pregunta General**
{pregunta_general}
**Pregunta Cuantiitativa**
{pregunta_cuantitativa}
")
Pregunta General
¿Qué relación existe entre la participación en un voluntariado
curricular y el desarrollo de conductas prosociales en estudiantes
universitarios?
Pregunta Cuantiitativa
¿Existe una diferencia significativa en los niveles de prosocialidad de
los estudiantes universitarios antes y después de participar en un
voluntariado curricular, medida con la escala de prosocialidad para
adultos de Caprara?
📊 Estadística descriptiva sociodemográfica
# Función para tabla APA
tabla_apa_unica <- function(variable, nombre_variable) {
variable <- as.character(variable)
variable <- trimws(variable)
variable <- variable[variable != "" & !is.na(variable)]
frec <- table(variable)
porc <- round(prop.table(frec) * 100, 1)
acum <- round(cumsum(porc), 1)
tabla <- data.frame(
Categoría = names(frec),
Frecuencia = as.vector(frec),
`% Frecuencia` = paste0(porc, "%"),
`% Acumulado` = paste0(acum, "%")
)
# Devuelve HTML directamente
kable(tabla, format = "html", align = "c",
caption = paste("Distribución de", nombre_variable)) %>%
kable_styling(full_width = FALSE, position = "center")
}
# Nombres estilo APA
nombres_apa <- c(
"Edad" = "Edad de los participantes",
"Sexo" = "Identidad de género",
"Estado_civil" = "Estado civil",
"Trabaja" = "Condición laboral",
"Residente" = "Residencia habitual",
"Vive_con" = "Personas con quienes vive",
"Grupo_vulnerabilidad" = "Pertenencia a grupo de vulnerabilidad",
"Tipo_familia" = "Tipo de familia",
"Num_personas_casa" = "Número de personas en el hogar",
"Nivel_socioeconomico" = "Nivel socioeconómico percibido",
"Involucramiento_familiar" = "Involucramiento familiar en voluntariado",
"Involucramiento_personal" = "Involucramiento personal en voluntariado",
"Gusto_voluntariado" = "Le gustaría realizar voluntariados en sus materias"
)
# Mostrar tablas en HTML
for (var in names(nombres_apa)) {
cat(paste0("\n\n### Variable: ", nombres_apa[[var]], "\n\n"))
print(tabla_apa_unica(datos[[var]], nombre_variable = nombres_apa[[var]]))
}
Variable: Edad de los participantes
Distribución de Edad de los participantes
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
18
|
23
|
54.8%
|
54.8%
|
19
|
12
|
28.6%
|
83.4%
|
20
|
3
|
7.1%
|
90.5%
|
21
|
2
|
4.8%
|
95.3%
|
22
|
2
|
4.8%
|
100.1%
|
Variable: Identidad de género
Distribución de Identidad de género
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Femenino
|
33
|
78.6%
|
78.6%
|
Masculino
|
9
|
21.4%
|
100%
|
Variable: Estado civil
Distribución de Estado civil
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Soltero
|
41
|
97.6%
|
97.6%
|
Union libre
|
1
|
2.4%
|
100%
|
Variable: Condición laboral
Distribución de Condición laboral
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
No
|
20
|
47.6%
|
47.6%
|
Si
|
22
|
52.4%
|
100%
|
Variable: Residencia habitual
Distribución de Residencia habitual
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Foraneo
|
23
|
54.8%
|
54.8%
|
Local
|
19
|
45.2%
|
100%
|
Variable: Personas con quienes vive
Distribución de Personas con quienes vive
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Familia
|
24
|
57.1%
|
57.1%
|
Roomies
|
16
|
38.1%
|
95.2%
|
Solo
|
2
|
4.8%
|
100%
|
Variable: Pertenencia a grupo de vulnerabilidad
Distribución de Pertenencia a grupo de vulnerabilidad
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Madre soltera
|
2
|
4.8%
|
4.8%
|
Ninguno
|
40
|
95.2%
|
100%
|
Variable: Tipo de familia
Distribución de Tipo de familia
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Extensa
|
7
|
16.7%
|
16.7%
|
Monoparental
|
6
|
14.3%
|
31%
|
Tradicional
|
29
|
69%
|
100%
|
Variable: Número de personas en el hogar
Distribución de Número de personas en el hogar
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
2
|
1
|
2.4%
|
2.4%
|
3
|
12
|
28.6%
|
31%
|
4
|
12
|
28.6%
|
59.6%
|
5
|
12
|
28.6%
|
88.2%
|
6
|
3
|
7.1%
|
95.3%
|
7
|
2
|
4.8%
|
100.1%
|
Variable: Nivel socioeconómico percibido
Distribución de Nivel socioeconómico percibido
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Bajo
|
4
|
9.5%
|
9.5%
|
Medio
|
38
|
90.5%
|
100%
|
Variable: Involucramiento familiar en voluntariado
Distribución de Involucramiento familiar en voluntariado
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
1
|
1
|
2.4%
|
2.4%
|
10
|
1
|
2.4%
|
4.8%
|
2
|
6
|
14.3%
|
19.1%
|
3
|
2
|
4.8%
|
23.9%
|
4
|
5
|
11.9%
|
35.8%
|
5
|
9
|
21.4%
|
57.2%
|
6
|
6
|
14.3%
|
71.5%
|
7
|
5
|
11.9%
|
83.4%
|
8
|
4
|
9.5%
|
92.9%
|
9
|
3
|
7.1%
|
100%
|
Variable: Involucramiento personal en voluntariado
Distribución de Involucramiento personal en voluntariado
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
1
|
4
|
9.5%
|
9.5%
|
2
|
7
|
16.7%
|
26.2%
|
3
|
5
|
11.9%
|
38.1%
|
4
|
6
|
14.3%
|
52.4%
|
5
|
6
|
14.3%
|
66.7%
|
6
|
8
|
19%
|
85.7%
|
7
|
3
|
7.1%
|
92.8%
|
8
|
1
|
2.4%
|
95.2%
|
9
|
2
|
4.8%
|
100%
|
Variable: Le gustaría realizar voluntariados en sus materias
Distribución de Le gustaría realizar voluntariados en sus materias
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
No
|
10
|
23.8%
|
23.8%
|
Si
|
32
|
76.2%
|
100%
|
Variable: Áreas de interés para voluntariados
Distribución de Áreas de interés para realizar voluntariados (respuestas
múltiples)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Ambiental-ecologíco
|
6
|
8%
|
8%
|
Educativo
|
20
|
26.7%
|
34.7%
|
Emergencias-desastres
|
13
|
17.3%
|
52%
|
No respondió
|
3
|
4%
|
56%
|
Salud
|
13
|
17.3%
|
73.3%
|
Social-comunitario
|
20
|
26.7%
|
100%
|
Variable: Ha realizado voluntariados previamente
Distribución de Ha realizado voluntariados previamente
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
No
|
17
|
40.5%
|
40.5%
|
Si
|
25
|
59.5%
|
100%
|
🤝 Sujetos que han participado previamente en voluntariados
Han participado en previamente voluntariado (n = 25)
tabla_apa_multiple <- function(variable, nombre_variable) {
df <- data.frame(respuesta = variable)
df <- df %>%
separate_rows(respuesta, sep = ",") %>%
mutate(respuesta = trimws(respuesta)) %>%
filter(
!is.na(respuesta),
respuesta != "",
toupper(respuesta) != "NA"
)
frec <- table(df$respuesta)
porc <- round(prop.table(frec) * 100, 1)
acum <- round(cumsum(porc), 1)
tabla <- data.frame(
Categoría = names(frec),
Frecuencia = as.vector(frec),
`% Frecuencia` = paste0(porc, "%"),
`% Acumulado` = paste0(acum, "%")
)
kable(tabla, format = "html", align = "c",
caption = paste("Distribución de", nombre_variable, "(respuestas múltiples)")) %>%
kable_styling(full_width = FALSE, position = "center")
}
Variables de respuesta múltiple
Cada tabla a continuación representa variables donde los
participantes podían seleccionar más de una opción. Las respuestas
fueron separadas por comas y desagregadas para su análisis. Esta
decisión metodológica permite visualizar la diversidad de experiencias y
motivaciones sin forzar exclusividad en las categorías.
Variable: Quién le involucró en el voluntariado
Distribución de Quién le involucró en el voluntariado (respuestas
múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Amigo
|
9
|
15.5%
|
15.5%
|
Escuela
|
16
|
27.6%
|
43.1%
|
Familia
|
10
|
17.2%
|
60.3%
|
Gobierno
|
1
|
1.7%
|
62%
|
NA
|
17
|
29.3%
|
91.3%
|
Religión
|
5
|
8.6%
|
99.9%
|
Variable: Tipos de voluntariado realizados
Distribución de Tipos de voluntariado realizados (respuestas múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Ambiental-ecológico
|
13
|
19.7%
|
19.7%
|
Educación
|
5
|
7.6%
|
27.3%
|
Emergencias-desastres
|
4
|
6.1%
|
33.4%
|
NA
|
17
|
25.8%
|
59.2%
|
Salud
|
6
|
9.1%
|
68.3%
|
Social-comunitario
|
21
|
31.8%
|
100.1%
|
Variable: Motivaciones para participar en voluntariados
Distribución de Motivaciones para participar en voluntariados
(respuestas múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Altruismo
|
5
|
8.8%
|
8.8%
|
Compromiso cívico
|
4
|
7%
|
15.8%
|
Desarrollo personal
|
13
|
22.8%
|
38.6%
|
Diversión
|
9
|
15.8%
|
54.4%
|
NA
|
17
|
29.8%
|
84.2%
|
Obligación
|
6
|
10.5%
|
94.7%
|
Reconocimiento
|
3
|
5.3%
|
100%
|
Variable: Beneficios percibidos de participar en voluntariados
Distribución de Beneficios percibidos de participar en voluntariados
(respuestas múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Autoestima
|
2
|
2.5%
|
2.5%
|
Conexión
|
6
|
7.4%
|
9.9%
|
Empatía
|
19
|
23.5%
|
33.4%
|
Experiencia
|
13
|
16%
|
49.4%
|
Habilidades
|
9
|
11.1%
|
60.5%
|
NA
|
17
|
21%
|
81.5%
|
Satisfacción
|
15
|
18.5%
|
100%
|
Variable: Lo que más recuerda del voluntariado
Distribución de Lo que más recuerda del voluntariado (respuestas
múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
A las personas
|
11
|
19%
|
19%
|
Lo que aprendí
|
7
|
12.1%
|
31.1%
|
Lo que hice
|
10
|
17.2%
|
48.3%
|
Lo que sentí
|
13
|
22.4%
|
70.7%
|
NA
|
17
|
29.3%
|
100%
|
🧤 Sujetos que no han participado previamente en voluntariados
No han participado en voluntariado previamente (n = 17)
tabla_apa_unica <- function(variable, nombre_variable) {
variable <- as.character(variable)
variable <- trimws(variable)
frec <- table(variable, useNA = "ifany")
porc <- round(prop.table(frec) * 100, 1)
acum <- round(cumsum(porc), 1)
tabla <- data.frame(
Categoría = names(frec),
Frecuencia = as.vector(frec),
`% Frecuencia` = paste0(porc, "%"),
`% Acumulado` = paste0(acum, "%")
)
kable(tabla, format = "html", align = "c",
caption = paste("Distribución de", nombre_variable)) %>%
kable_styling(full_width = FALSE, position = "center")
}
Variable: Le gustaría participar en un voluntariado
Distribución de Le gustaría participar en un voluntariado
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
NA
|
25
|
59.5%
|
59.5%
|
No
|
2
|
4.8%
|
64.3%
|
Si
|
15
|
35.7%
|
100%
|
Variables de respuesta múltiple
Cada tabla a continuación representa variables donde los
participantes podían seleccionar más de una opción. Las respuestas
fueron separadas por comas y desagregadas para su análisis. Esta
decisión metodológica permite visualizar la diversidad de experiencias y
motivaciones sin forzar exclusividad en las categorías.
Variable: Motivos para no participar en voluntariado
Distribución de Motivos para no participar en voluntariado (respuestas
múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Falta de interés
|
1
|
2.1%
|
2.1%
|
Falta de oportunidades
|
10
|
21.3%
|
23.4%
|
Falta de tiempo
|
9
|
19.1%
|
42.5%
|
NA
|
25
|
53.2%
|
95.7%
|
Prejuicios
|
2
|
4.3%
|
100%
|
Variable: Beneficios esperados del voluntariado
Distribución de Beneficios esperados del voluntariado (respuestas
múltiple)
Categoría
|
Frecuencia
|
X..Frecuencia
|
X..Acumulado
|
Amistades
|
5
|
7.4%
|
7.4%
|
Aprendizaje
|
13
|
19.1%
|
26.5%
|
Aventura
|
3
|
4.4%
|
30.9%
|
Consciencia
|
8
|
11.8%
|
42.7%
|
Curriculum
|
5
|
7.4%
|
50.1%
|
NA
|
25
|
36.8%
|
86.9%
|
Satisfacción
|
9
|
13.2%
|
100.1%
|
🧭 Pruebas de normalidad Escala de Prosocialidad
prueba_normalidad <- function(variable, nombre_dim) {
variable <- as.character(variable)
variable <- trimws(variable)
variable <- variable[!is.na(variable) & variable != "" & variable != "NA"]
variable <- as.numeric(variable)
cat(paste0("🧩 Variable: ", nombre_dim, "\n\n"))
if (length(variable) < 3) {
cat("⚠️ No se puede aplicar prueba de normalidad: menos de 3 datos válidos.\n")
} else {
# Shapiro-Wilk
shapiro <- shapiro.test(variable)
# Kolmogorov-Smirnov ajustado
ks <- ks.test(variable, "pnorm", mean(variable), sd(variable))
# Mostrar resultados
cat("🧪 Shapiro-Wilk:\n")
print(shapiro)
cat("\n🧪 Kolmogorov-Smirnov (ajustada):\n")
print(ks)
}
cat("\n", strrep("─", 50), "\n\n")
}
## Nota: El "Warning in ks.test.default" antes de cada prueba, se debe a que la prueba de Kolmogorov-Smirnov presentó valores repetidos (‘ties’) en las variables evaluadas, lo cual puede afectar la precisión del estadístico D. Por ello, se privilegió la interpretación de la prueba de Shapiro-Wilk como criterio principal de normalidad.
# Aplicar a cada dimensión
prueba_normalidad(datos$Ayudar_A, "Ayudar")
## 🧩 Variable: Ayudar
## Warning in ks.test.default(variable, "pnorm", mean(variable), sd(variable)):
## ties should not be present for the one-sample Kolmogorov-Smirnov test
## 🧪 Shapiro-Wilk:
##
## Shapiro-Wilk normality test
##
## data: variable
## W = 0.953, p-value = 0.08277
##
##
## 🧪 Kolmogorov-Smirnov (ajustada):
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: variable
## D = 0.12535, p-value = 0.5242
## alternative hypothesis: two-sided
##
##
## ──────────────────────────────────────────────────
prueba_normalidad(datos$Compartir_A, "Compartir")
## 🧩 Variable: Compartir
## Warning in ks.test.default(variable, "pnorm", mean(variable), sd(variable)):
## ties should not be present for the one-sample Kolmogorov-Smirnov test
## 🧪 Shapiro-Wilk:
##
## Shapiro-Wilk normality test
##
## data: variable
## W = 0.93241, p-value = 0.01563
##
##
## 🧪 Kolmogorov-Smirnov (ajustada):
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: variable
## D = 0.15943, p-value = 0.2361
## alternative hypothesis: two-sided
##
##
## ──────────────────────────────────────────────────
prueba_normalidad(datos$Empatia_A, "Empatía")
## 🧩 Variable: Empatía
## Warning in ks.test.default(variable, "pnorm", mean(variable), sd(variable)):
## ties should not be present for the one-sample Kolmogorov-Smirnov test
## 🧪 Shapiro-Wilk:
##
## Shapiro-Wilk normality test
##
## data: variable
## W = 0.93404, p-value = 0.01777
##
##
## 🧪 Kolmogorov-Smirnov (ajustada):
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: variable
## D = 0.11968, p-value = 0.5843
## alternative hypothesis: two-sided
##
##
## ──────────────────────────────────────────────────
prueba_normalidad(datos$Total_A, "Total prosocialidad")
## 🧩 Variable: Total prosocialidad
## Warning in ks.test.default(variable, "pnorm", mean(variable), sd(variable)):
## ties should not be present for the one-sample Kolmogorov-Smirnov test
## 🧪 Shapiro-Wilk:
##
## Shapiro-Wilk normality test
##
## data: variable
## W = 0.95451, p-value = 0.0938
##
##
## 🧪 Kolmogorov-Smirnov (ajustada):
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: variable
## D = 0.13979, p-value = 0.3846
## alternative hypothesis: two-sided
##
##
## ──────────────────────────────────────────────────
## 📈 Gráficos Q-Q plot de normalidad Escala de Prosocialidad
graficar_qqplot_individual <- function(variable, nombre_dim) {
variable <- as.character(variable)
variable <- trimws(variable)
variable <- variable[!is.na(variable) & variable != "" & variable != "NA"]
variable <- suppressWarnings(as.numeric(variable))
variable <- variable[!is.na(variable)]
nombre_dim <- trimws(nombre_dim)
n <- length(variable)
df <- data.frame(
observado = sort(variable),
teorico = qnorm(ppoints(n))
)
plot <- ggplot(df, aes(x = teorico, y = observado)) +
geom_point(color = "#3498DB", size = 2) +
geom_abline(slope = 1, intercept = 0, color = "#E74C3C",
linetype = "dashed", linewidth = 1) +
labs(
title = paste0("Q-Q Plot: ", nombre_dim),
x = "Cuantiles teóricos (Normal)",
y = "Cuantiles observados"
) +
theme_minimal(base_size = 12)
print(plot)
}
graficar_qqplot_individual(datos$Ayudar_A, "Ayudar")

graficar_qqplot_individual(datos$Empatia_A, "Empatía")

graficar_qqplot_individual(datos$Compartir_A, "Compartir")

graficar_qqplot_individual(datos$Total_A, "Total")

📍 Gráfico Bloxplot para identificación de sujetos fuera de los
parámetros
graficar_boxplot <- function(variable, nombre_dim, sujetos, entrevistados = c("9", "15", "19", "20", "41", "42")) {
variable <- as.character(variable)
sujetos <- as.character(sujetos)
# Filtrar simultáneamente
filtro <- !is.na(variable) & variable != "" & variable != "NA"
variable_filtrada <- suppressWarnings(as.numeric(variable[filtro]))
sujetos_filtrados <- sujetos[filtro]
df <- data.frame(Sujeto = sujetos_filtrados, Puntaje = variable_filtrada)
# Crear columna para color y leyenda
df$Entrevistado <- ifelse(df$Sujeto %in% entrevistados, "Sí", "No")
ggplot(df, aes(x = "", y = Puntaje)) +
geom_boxplot(fill = "#D5DBDB", outlier.color = "#E74C3C") +
geom_text(aes(label = Sujeto, color = Entrevistado),
position = position_jitter(width = 0.2),
size = 3.5) +
scale_color_manual(values = c("Sí" = "#E74C3C", "No" = "#7F8C8D")) +
labs(
title = paste("Boxplot con sujetos:", nombre_dim),
subtitle = "Sujetos entrevistados señalados en rojo",
x = "", y = "Puntaje",
color = "Entrevistado"
) +
theme_minimal(base_size = 12) +
theme(legend.position = "right")
}
# Graficar cada dimensión con etiquetas de Serie
graficar_boxplot(datos$Ayudar_A, "Ayudar", datos$Serie)

graficar_boxplot(datos$Compartir_A, "Compartir", datos$Serie)

graficar_boxplot(datos$Empatia_A, "Empatía", datos$Serie)

graficar_boxplot(datos$Total_A, "Total prosocialidad", datos$Serie)
