candidatos <- c("Totalltems_EventRecord", "TotalItems_EventRecord", "t_itemevt", "Total_Ítems_Evento", "Total_Items_Evento")
encontrados <- intersect(candidatos, names(datos))
col_v3 <- if (length(encontrados) > 0) encontrados[1] else names(datos)[1]
t_itemevt <- as.integer(round(suppressWarnings(as.numeric(datos[[col_v3]]))))
t_itemevt <- t_itemevt[!is.na(t_itemevt) & is.finite(t_itemevt) & t_itemevt >= 0]valores <- seq(from = min(t_itemevt), to = max(t_itemevt), by = 1)
ni <- as.integer(table(factor(t_itemevt, levels = valores)))
total_n <- sum(ni)
hi <- ni / total_n
porcentaje <- hi * 100
Ni_asc <- cumsum(ni)
Ni_desc <- rev(cumsum(rev(ni)))
Hi_asc_pct <- cumsum(porcentaje)
Hi_desc_pct <- rev(cumsum(rev(porcentaje)))tabla_freq <- data.frame(
Valor = as.character(valores),
ni = as.character(ni),
hi = sprintf("%.4f", hi),
`hi (%)` = sprintf("%.2f", porcentaje),
Ni_asc = as.character(Ni_asc),
`Hi (%)` = sprintf("%.2f", Hi_asc_pct),
check.names = FALSE
)
fila_total <- data.frame(
Valor = "Total",
ni = as.character(total_n),
hi = sprintf("%.4f", sum(hi)),
`hi (%)` = sprintf("%.2f", sum(porcentaje)),
Ni_asc = as.character(max(Ni_asc)),
`Hi (%)` = sprintf("%.2f", max(Hi_asc_pct)),
check.names = FALSE
)
kable(rbind(tabla_freq, fila_total), align = "c")| Valor | ni | hi | hi (%) | Ni_asc | Hi (%) |
|---|---|---|---|---|---|
| 0 | 10 | 0.0400 | 4.00 | 10 | 4.00 |
| 1 | 9 | 0.0360 | 3.60 | 19 | 7.60 |
| 2 | 9 | 0.0360 | 3.60 | 28 | 11.20 |
| 3 | 12 | 0.0480 | 4.80 | 40 | 16.00 |
| 4 | 5 | 0.0200 | 2.00 | 45 | 18.00 |
| 5 | 7 | 0.0280 | 2.80 | 52 | 20.80 |
| 6 | 8 | 0.0320 | 3.20 | 60 | 24.00 |
| 7 | 7 | 0.0280 | 2.80 | 67 | 26.80 |
| 8 | 6 | 0.0240 | 2.40 | 73 | 29.20 |
| 9 | 12 | 0.0480 | 4.80 | 85 | 34.00 |
| 10 | 7 | 0.0280 | 2.80 | 92 | 36.80 |
| 11 | 15 | 0.0600 | 6.00 | 107 | 42.80 |
| 12 | 16 | 0.0640 | 6.40 | 123 | 49.20 |
| 13 | 7 | 0.0280 | 2.80 | 130 | 52.00 |
| 14 | 7 | 0.0280 | 2.80 | 137 | 54.80 |
| 15 | 10 | 0.0400 | 4.00 | 147 | 58.80 |
| 16 | 9 | 0.0360 | 3.60 | 156 | 62.40 |
| 17 | 9 | 0.0360 | 3.60 | 165 | 66.00 |
| 18 | 13 | 0.0520 | 5.20 | 178 | 71.20 |
| 19 | 12 | 0.0480 | 4.80 | 190 | 76.00 |
| 20 | 7 | 0.0280 | 2.80 | 197 | 78.80 |
| 21 | 11 | 0.0440 | 4.40 | 208 | 83.20 |
| 22 | 8 | 0.0320 | 3.20 | 216 | 86.40 |
| 23 | 15 | 0.0600 | 6.00 | 231 | 92.40 |
| 24 | 11 | 0.0440 | 4.40 | 242 | 96.80 |
| 25 | 8 | 0.0320 | 3.20 | 250 | 100.00 |
| Total | 250 | 1.0000 | 100.00 | 250 | 100.00 |
las_ejes <- if (length(valores) <= 20) 1 else 2
barplot(ni, names.arg = valores, col = "skyblue3", las = las_ejes,
main = "5.1 Frecuencia absoluta (ni) - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "ni",
ylim = c(0, max(ni) * 1.15))
grid(nx = NA, ny = NULL, col = "gray85", lty = "dotted")barplot(ni, names.arg = valores, col = "skyblue3", las = las_ejes,
main = "5.2 Frecuencia respecto al total - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "ni",
ylim = c(0, total_n))
grid(nx = NA, ny = NULL, col = "gray85", lty = "dotted")barplot(porcentaje, names.arg = valores, col = "steelblue3", las = las_ejes,
main = "5.3 Porcentaje (%) - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "Porcentaje (%)",
ylim = c(0, max(porcentaje) * 1.15))
grid(nx = NA, ny = NULL, col = "gray85", lty = "dotted")barplot(porcentaje, names.arg = valores, col = "steelblue3", las = las_ejes,
main = "5.4 Porcentaje respecto a 100% - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "Porcentaje (%)",
ylim = c(0, 100))
grid(nx = NA, ny = NULL, col = "gray85", lty = "dotted")boxplot(t_itemevt, horizontal = TRUE, col = "#76D7C4", border = "black", pch = 19,
main = "6. Diagrama de caja horizontal - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)")
grid()plot(valores, Ni_asc, type = "b", col = "orange", pch = 19, lwd = 2,
ylim = c(0, total_n), main = "7.1 Ojivas absolutas - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "Frecuencia acumulada (Ni)")
lines(valores, Ni_desc, type = "b", col = "blue", pch = 19, lwd = 2)
grid(col = "gray85", lty = 1)
legend("topleft", legend = c("Ascendente", "Descendente"),
col = c("orange", "blue"), pch = 19, lty = 1, lwd = 2, bg = "white")plot(valores, Hi_asc_pct, type = "b", col = "orange", pch = 19, lwd = 2,
ylim = c(0, 100), main = "7.2 Ojivas porcentuales - Total_Ítems_Evento",
xlab = "Total_Ítems_Evento (Unidades: ítems / fragmentos)", ylab = "Porcentaje acumulado (%)")
lines(valores, Hi_desc_pct, type = "b", col = "blue", pch = 19, lwd = 2)
grid(col = "gray85", lty = 1)
legend("topleft", legend = c("Ascendente (%)", "Descendente (%)"),
col = c("orange", "blue"), pch = 19, lty = 1, lwd = 2, bg = "white")media_v3 <- mean(t_itemevt)
mediana_v3 <- median(t_itemevt)
moda_v3 <- paste(names(which(table(t_itemevt) == max(table(t_itemevt)))), collapse = ", ")
rango_v3 <- paste0(min(t_itemevt), " - ", max(t_itemevt))
q1_v3 <- quantile(t_itemevt, 0.25)
q3_v3 <- quantile(t_itemevt, 0.75)
ric_v3 <- IQR(t_itemevt)
atip_v3 <- unique(t_itemevt[t_itemevt < (q1_v3 - 1.5 * ric_v3) | t_itemevt > (q3_v3 + 1.5 * ric_v3)])
atip_txt <- if (length(atip_v3) == 0) "No existen" else paste(sort(atip_v3), collapse = ", ")
indicadores_v3 <- data.frame(
Indicador = c("Media", "Mediana", "Moda", "Rango", "Varianza", "Desviación estándar", "Asimetría", "Curtosis", "Valores atípicos"),
Valor = c(
sprintf("%.2f", media_v3),
sprintf("%.2f", mediana_v3),
moda_v3,
rango_v3,
sprintf("%.2f", var(t_itemevt)),
sprintf("%.2f", sd(t_itemevt)),
sprintf("%.2f", skewness(t_itemevt, type = 2)),
sprintf("%.2f", kurtosis(t_itemevt)),
atip_txt
),
stringsAsFactors = FALSE
)
kable(indicadores_v3, align = "c")| Indicador | Valor |
|---|---|
| Media | 13.01 |
| Mediana | 13.00 |
| Moda | 12 |
| Rango | 0 - 25 |
| Varianza | 56.06 |
| Desviación estándar | 7.49 |
| Asimetría | -0.12 |
| Curtosis | -1.17 |
| Valores atípicos | No existen |
cat(paste0(
"En **n = ", total_n, "** registros válidos de **Total_Ítems_Evento** (`t_itemevt`), la cantidad de elementos recolectados por evento fluctúa entre **",
min(t_itemevt), "** y **", max(t_itemevt), "**, con media de **", sprintf("%.2f", media_v3),
"**, mediana de **", sprintf("%.2f", mediana_v3), "**, moda en **", moda_v3,
"** y desviación estándar de **", sprintf("%.2f", sd(t_itemevt)), "**. Valores atípicos: **", atip_txt, "**."
))En n = 250 registros válidos de
Total_Ítems_Evento (t_itemevt), la
cantidad de elementos recolectados por evento fluctúa entre
0 y 25, con media de
13.01, mediana de 13.00, moda en
12 y desviación estándar de 7.49.
Valores atípicos: No existen.