# Data de la gestion adiministrativa
dataGA <-
readxl::read_excel(path = 'EdwinDatosTesis.xlsx',
sheet = 'GestionAdministrativa') %>%
setNames(paste0('GestionAdministrativa.', names(.)))
# Data de la calidad de servicio al usuario
dataAU <-
readxl::read_excel(path = 'EdwinDatosTesis.xlsx',
sheet = 'AtencionUsuario') %>%
setNames(paste0('AtencionUsuario.', names(.)))
# Consolidacion y generacion de nuevas columnas para la prueba de hipotesis
data.Ga.AU <-
dataGA %>%
dplyr::bind_cols(dataAU) %>%
dplyr::mutate(Planeacion = rowSums( .[, c(1:4)] ),
Organizacion = rowSums( .[, c(5:8)] ),
Direccion = rowSums( .[, c(9:12)] ),
Control = rowSums( .[, c(13:16)] ),
Total_GA = rowSums( .[, c(1:16)] ),
Total_AU = rowSums( .[, c(17:32)] )
)
instr <- unique(Resumen$sheets)
word.plots <- officer::read_docx()
for (i in 1:length(instr)) {
idata <-
Resumen %>%
dplyr::filter(sheets %in% instr[i])
jpreguntas <- unique(idata$Pregunta)
for (j in 1:length(jpreguntas)) {
jdata <-
idata %>%
dplyr::filter(Pregunta %in% jpreguntas[j]) %>%
dplyr::select(3:5)
# Data para la tabla
jtitlep <-
Consolidado %>%
dplyr::filter(sheets %in% instr[i],
Pregunta %in% jpreguntas[j]) %>%
dplyr::select(Etiqueta) %>%
dplyr::pull() %>%
unique()
# Titulo de la tabla
jtitle <- paste0('Distribución de datos para la pregunta: ', jtitlep)
# Tabla resumen por pregunta
jtabla <-
jdata %>%
dplyr::mutate(Porcentaje = paste0(Porcentaje*100, '%')) %>%
dplyr::rename_at(vars(label), ~as.character( jpreguntas[j]) )
grap <-
jdata %>%
ggplot2::ggplot() +
ggplot2::aes(x = label, y = Porcentaje, colour = label,
fill = label, label = scales::percent(Porcentaje)) +
ggplot2::geom_col(position = 'dodge') +
ggplot2::scale_fill_manual(values = colores) +
ggplot2::geom_text(position = position_dodge(width = .9),
vjust = 1,
size = 3, color = 'white',
fontface = "bold", family = 'serif') +
ggplot2::scale_y_continuous(labels = scales::percent_format())+
ggplot2::theme_minimal() +
ggthemes::scale_colour_excel_new() +
ggplot2::theme(legend.position = 'none',
text = ggplot2::element_text(family = 'serif', size = 7),
axis.title.y = ggplot2::element_blank(),
axis.text.x = ggplot2::element_text(size = 8, face = "bold"),
axis.text.y = ggplot2::element_text(size = 8, face = "bold"),
axis.title.x = ggplot2::element_blank())
dim.ques <-
officer::block_caption(
label = paste0(instr[i], '_', jpreguntas[j]),
style = 'table title',
autonum = NULL)
officer::body_add_caption(x = word.plots, value = dim.ques, pos = 'before')
officer::body_add_par(x = word.plots, value = " ")
title <- officer::block_caption(label = jtitle,
style = 'table title',
autonum = NULL)
officer::body_add_par(x = word.plots, value = "")
officer::body_add_caption(x = word.plots, value = title, pos = 'after')
officer::body_add_par(x = word.plots, value = "")
officer::body_add_table(word.plots, jtabla, style = 'table_template',
alignment = c('l', 'c', 'c'))
officer::body_add_par(x = word.plots, value = "")
officer::body_add_gg(x = word.plots, value = grap, width = 4, height = 4)
officer::body_add_par(x = word.plots, value = "")
officer::body_add_par(x = word.plots, value = "")
officer::body_add_par(x = word.plots, value = "")
officer::body_add_par(x = word.plots, value = "")
}
}
print(word.plots, target = 'word.plots.docx')
Se utiliza la correlacion por Spearman ya que son datos provenientes de cuestionarios.
Considerar que la correlacion es un medida que oscila entre -1 y +1.
Prueba de hipotesis para la correlacion:
Ejemplo:
##
## Spearman's rank correlation rho
##
## data: data.forzada$Total_GA and data.forzada$Total_AU
## S = 3616.3, p-value = 3.48e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.6607598
##
## Spearman's rank correlation rho
##
## data: data.forzada$Planeacion and data.forzada$Total_AU
## S = 4382.6, p-value = 6.41e-05
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.5888727
##
## Spearman's rank correlation rho
##
## data: data.forzada$Organizacion and data.forzada$Total_AU
## S = 3709.2, p-value = 5.159e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.6520494
##
## Spearman's rank correlation rho
##
## data: data.forzada$Direccion and data.forzada$Total_AU
## S = 4927.8, p-value = 0.0003457
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.5377318
##
## Spearman's rank correlation rho
##
## data: data.forzada$Control and data.forzada$Total_AU
## S = 3589, p-value = 3.092e-06
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.6633174
Se utiliza la prueba de Ji Cuadrada ya que se quiere evaluar si existe una dependencia entre las variables a probar.
Prueba de hipotesis para Ji Cuadrada:
Ejemplo:
# General: Gestion Administrativa vs Calidad del servicio al usuario
cc.hg <-
chisq.test(x = data.forzada$Total_GA,
y = data.forzada$Total_AU, );cc.hg
##
## Pearson's Chi-squared test
##
## data: data.forzada$Total_GA and data.forzada$Total_AU
## X-squared = 546.67, df = 323, p-value = 9.649e-14
# Especifica 01: (Planeacion vs Calidad del servicio al usuario)
cc.01 <-
chisq.test(x = data.forzada$Planeacion,
y = data.forzada$Total_AU);cc.01
##
## Pearson's Chi-squared test
##
## data: data.forzada$Planeacion and data.forzada$Total_AU
## X-squared = 314.84, df = 190, p-value = 3.206e-08
# Especifica 02: (Organizacion vs Calidad del servicio al usuario)
cc.02 <-
chisq.test(x = data.forzada$Organizacion,
y = data.forzada$Total_AU);cc.02
##
## Pearson's Chi-squared test
##
## data: data.forzada$Organizacion and data.forzada$Total_AU
## X-squared = 382.67, df = 209, p-value = 2.507e-12
# Especifica 03: (Direccion vs Calidad del servicio al usuario)
cc.03 <-
chisq.test(x = data.forzada$Direccion,
y = data.forzada$Total_AU);cc.03
##
## Pearson's Chi-squared test
##
## data: data.forzada$Direccion and data.forzada$Total_AU
## X-squared = 291.67, df = 190, p-value = 2.932e-06
# Especifica 04: (Control vs Calidad del servicio al usuario)
cc.04 <-
chisq.test(x = data.forzada$Control,
y = data.forzada$Total_AU);cc.04
##
## Pearson's Chi-squared test
##
## data: data.forzada$Control and data.forzada$Total_AU
## X-squared = 383.89, df = 209, p-value = 1.886e-12
Prueba de correlacion segun Spearman entre la Gestion Administrativa y la calidad de servicio | |||
| Prueba | Valor del estadistico | P Valor |
Gestion Administrativa y | Rho de Spearman | 0.661 | 0.000 |
X-squared | 546.667 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||
Prueba de correlacion segun Spearman entre la Planeacion y la calidad de servicio | |||
| Prueba | Valor del estadistico | P Valor |
Planeamiento | Rho de Spearman | 0.589 | 0.000 |
X-squared | 314.841 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||
Prueba de correlacion segun Spearman entre la Organizacion y la calidad de servicio | |||
| Prueba | Valor del estadistico | P Valor |
Organizacion | Rho de Spearman | 0.652 | 0.000 |
X-squared | 382.667 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||
Prueba de correlacion segun Spearman entre la Direccion y la calidad de servicio | |||
| Prueba | Valor del estadistico | P Valor |
Direccion | Rho de Spearman | 0.538 | 0.000 |
X-squared | 291.667 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||
Prueba de correlacion segun Spearman entre el Control y la calidad de servicio | |||
| Prueba | Valor del estadistico | P Valor |
Control | Rho de Spearman | 0.663 | 0.000 |
X-squared | 383.889 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||
Prueba de correlacion por Spearman y Ji Cuadrada (X-squared) | |||
| Prueba | Valor del estadistico | P Valor |
Gestion Administrativa y | Rho de Spearman | 0.661 | 0.000 |
X-squared | 546.667 | 0.000 | |
Planeamiento | Rho de Spearman | 0.589 | 0.000 |
X-squared | 314.841 | 0.000 | |
Organizacion | Rho de Spearman | 0.652 | 0.000 |
X-squared | 382.667 | 0.000 | |
Direccion | Rho de Spearman | 0.538 | 0.000 |
X-squared | 291.667 | 0.000 | |
Control | Rho de Spearman | 0.663 | 0.000 |
X-squared | 383.889 | 0.000 | |
** 0.000 indica que la correlacion es significativa al 0.01 (bilateral) | |||