library(summarytools)
library(reshape2)
library("readxl")
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(tidyr)
## 
## Adjuntando el paquete: 'tidyr'
## The following object is masked from 'package:reshape2':
## 
##     smiths
rutadearchivo="C:/Users/PERSONAL/Desktop/vinculacion/EncuestasUESFA.xlsx"

Datavinculacion=read_excel(rutadearchivo)
Datavinculacion
## # A tibble: 24 × 39
##    n     Sexo   Edad Zona     P1    P2    P3    P4    P5    P6    P7    P8    P9
##    <chr> <chr> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 E1    F        17 Urba…     3     4     4     2     2     3     3     2     2
##  2 E2    F        17 Rural     4     4     4     3     3     4     2     3     3
##  3 E3    F        17 Urba…     3     4     5     2     2     3     2     2     3
##  4 E4    M        16 Urba…     3     5     4     2     4     4     1     3     3
##  5 E5    F        16 Rural     5     4     4     3     3     3     2     4     3
##  6 E6    M        17 Rural     3     4     4     3     3     2     2     1     2
##  7 E7    M        17 Urba…     3     4     5     2     3     3     3     1     3
##  8 E8    F        16 Urba…     4     4     4     2     3     3     1     1     4
##  9 E9    M        17 Urba…     4     5     4     3     4     3     2     3     3
## 10 E10   M        16 Urba…     4     4     3     3     3     3     2     3     2
## # ℹ 14 more rows
## # ℹ 26 more variables: P10 <dbl>, P11 <dbl>, P12 <dbl>, P13 <dbl>, P14 <dbl>,
## #   P15 <dbl>, P16 <dbl>, P17 <dbl>, P18 <dbl>, P19 <dbl>, P20 <dbl>,
## #   P21 <dbl>, P22 <dbl>, P23 <dbl>, P24 <dbl>, P25 <dbl>, P26 <dbl>,
## #   P27 <dbl>, P28 <dbl>, P29 <dbl>, P30 <dbl>, P31 <dbl>, P32 <dbl>,
## #   P33 <dbl>, P34 <dbl>, P35 <dbl>
rutadearchivo1="C:/Users/PERSONAL/Desktop/vinculacion/Encuestas_opciones.xlsx"

Datavinculacionl=read_excel(rutadearchivo1)
Datavinculacionl
## # A tibble: 24 × 35
##    ESTUDIANTES Sexo   Edad Zona  P1    P2    P3    P4    P5    P6    P7    P8   
##    <chr>       <chr> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
##  1 E1          F        17 Urba… Neut… De a… De a… Muy … Muy … Algo  Algo  Casi…
##  2 E2          F        17 Rural De a… De a… De a… Algo  Algo  Bast… Muy … A ve…
##  3 E3          F        17 Urba… Neut… De a… Tota… Muy … Muy … Algo  Muy … Casi…
##  4 E4          M        16 Urba… Neut… Tota… De a… Muy … Bast… Bast… Nada  A ve…
##  5 E5          F        16 Rural Tota… De a… De a… Algo  Algo  Algo  Muy … Frec…
##  6 E6          M        17 Rural Neut… De a… De a… Algo  Algo  Muy … Muy … Nunca
##  7 E7          M        17 Urba… Neut… De a… Tota… Muy … Algo  Algo  Algo  Nunca
##  8 E8          F        16 Urba… De a… De a… De a… Muy … Algo  Algo  Nada  Nunca
##  9 E9          M        17 Urba… De a… Tota… De a… Algo  Bast… Algo  Muy … A ve…
## 10 E10         M        16 Urba… De a… De a… Neut… Algo  Algo  Algo  Muy … A ve…
## # ℹ 14 more rows
## # ℹ 23 more variables: P9 <chr>, P10 <chr>, P11 <chr>, P12 <chr>, P13 <chr>,
## #   P14 <chr>, P15 <chr>, P16 <chr>, P17 <chr>, P18 <chr>, P19 <chr>,
## #   P20 <chr>, P21 <chr>, P22 <chr>, P23 <chr>, P24 <chr>, P25 <chr>,
## #   P26 <chr>, P27 <chr>, P28 <chr>, P29 <chr>, P30 <chr>, P31 <chr>
library(psych)
## 
## Adjuntando el paquete: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
datos <- Datavinculacion[, paste0("P", 5:35)]

# Aplica el Alfa de Cronbach
resultado <- alpha(datos)
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in alpha(datos): Some items were negatively correlated with the first principal component and probably 
## should be reversed.  
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( P7 P21 P33 P34 P35 ) were negatively correlated with the first principal component and 
## probably should be reversed.  
## To do this, run the function again with the 'check.keys=TRUE' option
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
## In smc, smcs < 0 were set to .0
print(resultado$total$raw_alpha)  # Solo el valor
## [1] 0.7322394