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
library(readxl)
library(texreg)
## Version:  1.39.3
## Date:     2023-11-09
## Author:   Philip Leifeld (University of Essex)
## 
## Consider submitting praise using the praise or praise_interactive functions.
## Please cite the JSS article in your publications -- see citation("texreg").
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:texreg':
## 
##     extract
library(ggpubr)
## Loading required package: ggplot2
Survey <- read_excel("SurveyFinal.xlsx", sheet = "Sheet0")
head(Survey)
## # A tibble: 6 × 21
##   acepto edad  genero    pref_partidos candidatos voto  competente_c_1 lider_c_1
##   <chr>  <chr> <chr>     <chr>         <chr>      <chr> <chr>          <chr>    
## 1 Acepto 20    Femenino  No tengo nin… Jorge Álv… Xóch… 3              3        
## 2 Acepto 20    Femenino  No tengo nin… Jorge Álv… Xóch… 4              3        
## 3 Acepto 23    Femenino  No tengo nin… Jorge Álv… Anul… 4              3        
## 4 Acepto 21    Masculino No tengo nin… Jorge Álv… Xóch… <NA>           <NA>     
## 5 Acepto 23    Femenino  No tengo nin… Jorge Álv… Xóch… 3              4        
## 6 Acepto 22    Femenino  PAN           Jorge Álv… Xóch… <NA>           <NA>     
## # ℹ 13 more variables: amigable_c_1 <chr>, honesto_c_1 <chr>,
## #   empatico_c_1 <dbl>, sentimientos_c_1 <chr>, competente_t_1 <dbl>,
## #   lider_t_1 <chr>, amigable_t_1 <chr>, honesto_t_1 <chr>, empatico_t_1 <chr>,
## #   sentimientos_t_1 <chr>, maynezmaynez <chr>, ultima <chr>, Music <chr>
Clean_Surv = Survey%>%
  mutate(Music = as.factor(Music))%>%
  mutate(edad = as.numeric(edad))%>%
  mutate(competente_c = as.numeric(competente_c_1))%>%
  mutate(lider_c = as.numeric(lider_c_1))%>%
  mutate(amigable_c = as.numeric(amigable_c_1))%>%
  mutate(honesto_c = as.numeric(honesto_c_1))%>%
  mutate(empatico_c = as.numeric(empatico_c_1))%>%
  mutate(sentimientos_c = as.numeric(sentimientos_c_1))%>%
  mutate(competente_t = as.numeric(competente_t_1))%>%
  mutate(lider_t = as.numeric(lider_t_1))%>%
  mutate(amigable_t = as.numeric(amigable_t_1))%>%
  mutate(honesto_t = as.numeric(honesto_t_1))%>%
  mutate(empatico_t = as.numeric(empatico_t_1))%>%
  mutate(sentimientos_t = as.numeric(sentimientos_t_1))%>%
  mutate(candidatos = ifelse(candidatos == "Jorge Álvarez Máynez,Xóchitl Gálvez Ruiz,Claudia Sheinbaum Pardo", "Sí sabe", "No sabe"))%>%
  mutate(pref_partido = ifelse(pref_partidos == "Movimiento Ciudadano", "Simpatizantes", "No simpatizantes"))%>%
  mutate(maynezmaynez = as.factor(maynezmaynez))%>%
  mutate(voto = ifelse(voto == "Jorge Álvarez Máynez", "Simpatizantes","No simpatizantes"))%>%
  select(edad, genero, pref_partido, candidatos, voto, competente_c, lider_c, amigable_c, honesto_c, empatico_c, sentimientos_c, competente_t, lider_t, amigable_t, honesto_t, empatico_t, sentimientos_t, maynezmaynez, Music)
age_mean = mean(Clean_Surv$edad)
age_mean
## [1] 21.75269
age_sd = sd(Clean_Surv$edad)
age_sd
## [1] 2.509356
conteo_genero <- table(Clean_Surv$genero)
proporcion_genero <- prop.table(conteo_genero)
print(proporcion_genero)
## 
##                  Femenino                 Masculino No binario/ tercer género 
##                0.54838710                0.44086022                0.01075269
conteo_grupos <- table(Clean_Surv$Music)
names(conteo_grupos) <- c("Control", "Treatment")
proporcion_grupos = prop.table(conteo_grupos)
print(proporcion_grupos)
##   Control Treatment 
## 0.5376344 0.4623656

#1st regression model

# Nueva base con columnas por grupos, preguntas y respuestas (6 filas por cada encuestado)
encuesta_long <- Clean_Surv %>%
  pivot_longer(cols = c(competente_c, lider_c, amigable_c, honesto_c, empatico_c, sentimientos_c,
                        competente_t, lider_t, amigable_t, honesto_t, empatico_t, sentimientos_t),
               names_to = c("pregunta", "grupo"),
               names_sep = "_",
               values_to = "respuesta") %>%
  mutate(grupo = ifelse(grupo == "t", "tratamiento", "control"),
         grupo = as.factor(grupo))

# lista vacia para poner los modelos
modelos0 <- list()

for (preg in unique(encuesta_long$pregunta)) {
  datos_pregunta <- encuesta_long %>% filter(pregunta == preg)
  modelo0 <- lm(respuesta ~ grupo, data = datos_pregunta)
  modelos0[[preg]] <- modelo0
  cat("\nResumen del modelo para", preg, ":\n")
  print(summary(modelo0))
  
  screenreg(modelos0)
}
## 
## Resumen del modelo para competente :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.5000 -0.5000 -0.1628  0.8372  1.8372 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.5000     0.1362  25.704   <2e-16 ***
## grupotratamiento  -0.3372     0.2002  -1.684   0.0956 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9628 on 91 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.03022,    Adjusted R-squared:  0.01956 
## F-statistic: 2.836 on 1 and 91 DF,  p-value: 0.09562
## 
## 
## Resumen del modelo para lider :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0000 -0.8605  0.0000  0.1395  2.1395 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.0000     0.1215  24.692   <2e-16 ***
## grupotratamiento  -0.1395     0.1787  -0.781    0.437    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8591 on 91 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.006657,   Adjusted R-squared:  -0.004259 
## F-statistic: 0.6099 on 1 and 91 DF,  p-value: 0.4369
## 
## 
## Resumen del modelo para amigable :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.8372 -0.1600  0.1628  0.8400  1.1628 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.1600     0.1263  32.937   <2e-16 ***
## grupotratamiento  -0.3228     0.1857  -1.738   0.0856 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8931 on 91 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.03212,    Adjusted R-squared:  0.02149 
## F-statistic:  3.02 on 1 and 91 DF,  p-value: 0.08562
## 
## 
## Resumen del modelo para honesto :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.97959  0.02041  0.02041  0.16279  2.16279 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        2.9796     0.1052  28.313   <2e-16 ***
## grupotratamiento  -0.1424     0.1539  -0.925    0.357    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7367 on 90 degrees of freedom
##   (94 observations deleted due to missingness)
## Multiple R-squared:  0.009417,   Adjusted R-squared:  -0.00159 
## F-statistic: 0.8556 on 1 and 90 DF,  p-value: 0.3575
## 
## 
## Resumen del modelo para empatico :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.4000 -0.4186  0.5814  0.6000  1.6000 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.4000     0.1227  27.717   <2e-16 ***
## grupotratamiento   0.0186     0.1804   0.103    0.918    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8674 on 91 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.0001169,  Adjusted R-squared:  -0.01087 
## F-statistic: 0.01064 on 1 and 91 DF,  p-value: 0.9181
## 
## 
## Resumen del modelo para sentimientos :
## 
## Call:
## lm(formula = respuesta ~ grupo, data = datos_pregunta)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.920 -1.814  0.186  1.186  4.186 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        5.9200     0.3159  18.737   <2e-16 ***
## grupotratamiento  -0.1060     0.4646  -0.228     0.82    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.234 on 91 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.0005721,  Adjusted R-squared:  -0.01041 
## F-statistic: 0.05209 on 1 and 91 DF,  p-value: 0.82

#2nd regression model

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.4
## ✔ lubridate 1.9.3     ✔ stringr   1.5.0
## ✔ purrr     1.0.2     ✔ tibble    3.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks texreg::extract()
## ✖ 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
# Nueva base con columnas por grupos, preguntas y respuestas (6 filas por cada encuestado)
encuesta_long <- Clean_Surv %>%
  pivot_longer(cols = c(competente_c, lider_c, amigable_c, honesto_c, empatico_c, sentimientos_c,
                        competente_t, lider_t, amigable_t, honesto_t, empatico_t, sentimientos_t),
               names_to = c("pregunta", "grupo"),
               names_sep = "_",
               values_to = "respuesta") %>%
  mutate(grupo = ifelse(grupo == "t", "tratamiento", "control"),
         grupo = as.factor(grupo))

# lista vacia para poner los modelos
modelos <- list()

for (preg in unique(encuesta_long$pregunta)) {
  datos_pregunta <- encuesta_long %>% filter(pregunta == preg)
  modelo <- lm(respuesta ~ grupo*voto, data = datos_pregunta)
  modelos[[preg]] <- modelo
  cat("\nResumen del modelo para", preg, ":\n")
  print(summary(modelo))
}
## 
## Resumen del modelo para competente :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.30000 -0.30000 -0.08108  0.70000  1.91892 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                          3.3000     0.1447  22.798  < 2e-16 ***
## grupotratamiento                    -0.2189     0.2088  -1.048  0.29730    
## votoSimpatizantes                    1.0000     0.3237   3.090  0.00267 ** 
## grupotratamiento:votoSimpatizantes  -0.4144     0.5168  -0.802  0.42477    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9155 on 89 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.1425, Adjusted R-squared:  0.1136 
## F-statistic: 4.932 on 3 and 89 DF,  p-value: 0.003248
## 
## 
## Resumen del modelo para lider :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8500 -0.8108  0.1500  0.1892  2.1892 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         2.85000    0.13198  21.594   <2e-16 ***
## grupotratamiento                   -0.03919    0.19039  -0.206   0.8374    
## votoSimpatizantes                   0.75000    0.29511   2.541   0.0128 *  
## grupotratamiento:votoSimpatizantes -0.39414    0.47122  -0.836   0.4051    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8347 on 89 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.08288,    Adjusted R-squared:  0.05197 
## F-statistic: 2.681 on 3 and 89 DF,  p-value: 0.05163
## 
## 
## Resumen del modelo para amigable :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.7838 -0.1667  0.2162  0.5000  1.2162 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         4.07500    0.14060  28.982   <2e-16 ***
## grupotratamiento                   -0.29122    0.20283  -1.436    0.155    
## votoSimpatizantes                   0.42500    0.31440   1.352    0.180    
## grupotratamiento:votoSimpatizantes -0.04212    0.50201  -0.084    0.933    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8893 on 89 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.06148,    Adjusted R-squared:  0.02985 
## F-statistic: 1.944 on 3 and 89 DF,  p-value: 0.1283
## 
## 
## Resumen del modelo para honesto :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7949 -0.7000  0.2051  0.2162  2.2162 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         2.79487    0.11005  25.397  < 2e-16 ***
## grupotratamiento                   -0.01109    0.15772  -0.070 0.944112    
## votoSimpatizantes                   0.90513    0.24360   3.716 0.000355 ***
## grupotratamiento:votoSimpatizantes -0.52225    0.38836  -1.345 0.182162    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6872 on 88 degrees of freedom
##   (94 observations deleted due to missingness)
## Multiple R-squared:  0.157,  Adjusted R-squared:  0.1283 
## F-statistic: 5.464 on 3 and 88 DF,  p-value: 0.001721
## 
## 
## Resumen del modelo para empatico :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2500 -0.3243  0.0000  0.6757  1.7500 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         3.25000    0.13155  24.705   <2e-16 ***
## grupotratamiento                    0.07432    0.18977   0.392   0.6963    
## votoSimpatizantes                   0.75000    0.29416   2.550   0.0125 *  
## grupotratamiento:votoSimpatizantes -0.07432    0.46969  -0.158   0.8746    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.832 on 89 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.1003, Adjusted R-squared:  0.06993 
## F-statistic: 3.306 on 3 and 89 DF,  p-value: 0.02382
## 
## 
## Resumen del modelo para sentimientos :
## 
## Call:
## lm(formula = respuesta ~ grupo * voto, data = datos_pregunta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.5405 -1.5405  0.4595  1.4595  4.4595 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         5.47500    0.33300  16.441  < 2e-16 ***
## grupotratamiento                    0.06554    0.48038   0.136  0.89179    
## votoSimpatizantes                   2.22500    0.74461   2.988  0.00363 ** 
## grupotratamiento:votoSimpatizantes -0.26554    1.18894  -0.223  0.82378    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.106 on 89 degrees of freedom
##   (93 observations deleted due to missingness)
## Multiple R-squared:  0.1313, Adjusted R-squared:  0.1021 
## F-statistic: 4.486 on 3 and 89 DF,  p-value: 0.005585
screenreg(modelos)
## 
## ========================================================================================================
##                                     competente  lider      amigable   honesto    empatico   sentimientos
## --------------------------------------------------------------------------------------------------------
## (Intercept)                          3.30 ***    2.85 ***   4.07 ***   2.79 ***   3.25 ***   5.48 ***   
##                                     (0.14)      (0.13)     (0.14)     (0.11)     (0.13)     (0.33)      
## grupotratamiento                    -0.22       -0.04      -0.29      -0.01       0.07       0.07       
##                                     (0.21)      (0.19)     (0.20)     (0.16)     (0.19)     (0.48)      
## votoSimpatizantes                    1.00 **     0.75 *     0.43       0.91 ***   0.75 *     2.23 **    
##                                     (0.32)      (0.30)     (0.31)     (0.24)     (0.29)     (0.74)      
## grupotratamiento:votoSimpatizantes  -0.41       -0.39      -0.04      -0.52      -0.07      -0.27       
##                                     (0.52)      (0.47)     (0.50)     (0.39)     (0.47)     (1.19)      
## --------------------------------------------------------------------------------------------------------
## R^2                                  0.14        0.08       0.06       0.16       0.10       0.13       
## Adj. R^2                             0.11        0.05       0.03       0.13       0.07       0.10       
## Num. obs.                           93          93         93         92         93         93          
## ========================================================================================================
## *** p < 0.001; ** p < 0.01; * p < 0.05
library(ggplot2)

coeficientes <- data.frame()

for (preg in names(modelos)) {
  modelo <- modelos[[preg]]
  coefs <- summary(modelo)$coefficients
  coefs <- data.frame(Variable = rownames(coefs), Estimate = coefs[, "Estimate"])
  coefs$Pregunta <- preg
  coeficientes <- rbind(coeficientes, coefs)
}

preguntas <- unique(coeficientes$Pregunta)
resultados <- data.frame()

for (preg in preguntas) {
  intercepto <- coeficientes %>% filter(Pregunta == preg & Variable == "(Intercept)") %>% pull(Estimate)
  tratamiento <- coeficientes %>% filter(Pregunta == preg & Variable == "grupotratamiento") %>% pull(Estimate)
  simpatizantes <- coeficientes %>% filter(Pregunta == preg & Variable == "votoSimpatizantes") %>% pull(Estimate)
  interaccion <- coeficientes %>% filter(Pregunta == preg & Variable == "grupotratamiento:votoSimpatizantes") %>% pull(Estimate)
  

  simpatizantes_control <- intercepto + simpatizantes
  simpatizantes_tratamiento <- intercepto + tratamiento + simpatizantes + interaccion
  no_simpatizantes_control <- intercepto
  no_simpatizantes_tratamiento <- intercepto + tratamiento
  

  df <- data.frame(
    Pregunta = preg,
    Group = c("Supporters No Music", "Supporters Music", "Not Supporters No Music", "Not Supporters Music"),
    Coeficiente = c(simpatizantes_control, simpatizantes_tratamiento, no_simpatizantes_control, no_simpatizantes_tratamiento)
  )
  
  resultados <- rbind(resultados, df)
}

colores <- c("Supporters No Music" = "orange", 
                            "Supporters Music" = "darkorange", 
                            "Not Supporters No Music" = "blue", 
                            "Not Supporters Music" = "darkblue")
graficos <- list()

for (preg in preguntas) {
  datos_pregunta <- resultados %>% filter(Pregunta == preg)
  
  p <- ggplot(datos_pregunta, aes(x = Group, y = Coeficiente, fill = Group)) +
    geom_bar(stat = "identity", position = "dodge") +
    labs(title = paste(preg),
         x = "Group",
         y = "Coefficient") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
    scale_fill_manual(values = colores)
  
  graficos[[preg]] <- p
}

# Organizar los gráficos usando ggarrange
ggarrange(plotlist = graficos, ncol = 2, nrow = ceiling(length(graficos)/2))

Mean and Standard deviation

datos_Control <- Clean_Surv %>%
  filter(Music == 0)
datos_Tratamiento <- Clean_Surv %>%
  filter(Music == 1)

preguntas_control <- c("competente_c", "lider_c", "amigable_c", "honesto_c", "empatico_c", "sentimientos_c")
preguntas_tratamiento <- c("competente_t", "lider_t", "amigable_t", "honesto_t", "empatico_t", "sentimientos_t")

varianzas_control <- list()
varianzas_tratamiento <- list()
medias_control <- list()
medias_tratamiento <- list()

for (pregc in preguntas_control) {
  varianza <- var(datos_Control[[pregc]], na.rm = TRUE)
  media <- mean(datos_Control[[pregc]], na.rm = TRUE)
  varianzas_control[[pregc]] <- varianza
  medias_control[[pregc]] <- media
}

for (pregt in preguntas_tratamiento) {
  varianza <- var(datos_Tratamiento[[pregt]], na.rm = TRUE)
  media <- mean(datos_Tratamiento[[pregt]], na.rm = TRUE)
  varianzas_tratamiento[[pregt]] <- varianza
  medias_tratamiento[[pregt]] <- media
}

df_varianzas_control <- data.frame(Variable = preguntas_control, Varianza_Control = unlist(varianzas_control))
df_varianzas_tratamiento <- data.frame(Variable = preguntas_tratamiento, Varianza_Tratamiento = unlist(varianzas_tratamiento))
df_medias_control <- data.frame(Variable = preguntas_control, Media_Control = unlist(medias_control))
df_medias_tratamiento <- data.frame(Variable = preguntas_tratamiento, Media_Tratamiento = unlist(medias_tratamiento))

print(df_varianzas_control)
##                      Variable Varianza_Control
## competente_c     competente_c        0.9897959
## lider_c               lider_c        0.8163265
## amigable_c         amigable_c        0.7085714
## honesto_c           honesto_c        0.6037415
## empatico_c         empatico_c        0.8979592
## sentimientos_c sentimientos_c        5.7893878
print(df_varianzas_tratamiento)
##                      Variable Varianza_Tratamiento
## competente_t     competente_t            0.8538206
## lider_t               lider_t            0.6467331
## amigable_t         amigable_t            0.9014396
## honesto_t           honesto_t            0.4728682
## empatico_t         empatico_t            0.5825028
## sentimientos_t sentimientos_t            4.0598007
print(df_medias_control)
##                      Variable Media_Control
## competente_c     competente_c      3.500000
## lider_c               lider_c      3.000000
## amigable_c         amigable_c      4.160000
## honesto_c           honesto_c      2.979592
## empatico_c         empatico_c      3.400000
## sentimientos_c sentimientos_c      5.920000
print(df_medias_tratamiento)
##                      Variable Media_Tratamiento
## competente_t     competente_t          3.162791
## lider_t               lider_t          2.860465
## amigable_t         amigable_t          3.837209
## honesto_t           honesto_t          2.837209
## empatico_t         empatico_t          3.418605
## sentimientos_t sentimientos_t          5.813953