norm_pos <- function(x) (x - min(x, na.rm=TRUE)) / (max(x, na.rm=TRUE) - min(x, na.rm=TRUE))
norm_neg <- function(x) 1 - (x - min(x, na.rm=TRUE)) / (max(x, na.rm=TRUE) - min(x, na.rm=TRUE))
IDH_indices <- data.frame(
Country = IDH$Country,
Agr = IDH$Agr,
I_Escol = norm_pos(Xnum$Escolaridad),
I_Esp = norm_pos(Xnum$Esperanza),
I_PIB = norm_pos(log(Xnum$PIB)),
I_Gini = norm_neg(Xnum$Gini),
I_Desemp = norm_neg(Xnum$Desempleo),
I_Cext = norm_pos(Xnum$Cexterior),
stringsAsFactors = FALSE
)
apa_table(
data.frame(
Dimensión = c("Educación", "Salud", "Ingreso", "Equidad", "Empleo", "Apertura"),
Variable = c("Escolaridad", "Esperanza", "PIB (log)", "Gini", "Desempleo", "Cexterior"),
Sentido = c("Positivo", "Positivo", "Positivo", "Negativo (invertido)",
"Negativo (invertido)", "Positivo"),
Rango = c(
paste0("[", round(min(IDH_indices$I_Escol, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_Escol, na.rm=TRUE), 3), "]"),
paste0("[", round(min(IDH_indices$I_Esp, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_Esp, na.rm=TRUE), 3), "]"),
paste0("[", round(min(IDH_indices$I_PIB, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_PIB, na.rm=TRUE), 3), "]"),
paste0("[", round(min(IDH_indices$I_Gini, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_Gini, na.rm=TRUE), 3), "]"),
paste0("[", round(min(IDH_indices$I_Desemp, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_Desemp, na.rm=TRUE), 3), "]"),
paste0("[", round(min(IDH_indices$I_Cext, na.rm=TRUE), 3), ", ",
round(max(IDH_indices$I_Cext, na.rm=TRUE), 3), "]")
)
),
col.names = c("Dimensión", "Variable original", "Sentido", "Rango [0, 1]"),
caption = "Índices Normalizados Min-Max por Dimensión",
align = c("l", "l", "l", "c")
)