library(gt)
library(ggplot2)
library(dplyr)
library(knitr)
library(scales)
library(e1071)
datos <- read.csv(
"floricultura_cayambe_100.csv",
header = TRUE,
sep = ",",
na.strings = c("", "-", "NA"),
check.names = FALSE
)
# ==============================================================================
# Selección y conversión a numérico de rendimiento_tallos_ha
rendimiento <- suppressWarnings(as.numeric(datos[["rendimiento_tallos_ha"]]))
rendimiento <- rendimiento[is.finite(rendimiento)]
n <- length(rendimiento)
min_rend <- min(rendimiento)
max_rend <- max(rendimiento)
# ==============================================================================
# Calculo de frecuencia (Regla de Sturges)
R <- max_rend - min_rend
k_detallado <- ceiling(1 + 3.322 * log10(n))
A <- R / k_detallado
cat("Número de intervalos (k):", k_detallado, "\n")
## Número de intervalos (k): 8
Li <- seq(from = min_rend, to = max_rend - A, by = A)
Ls <- c(seq(from = min_rend + A, to = max_rend - A, by = A), max_rend)
rendimiento <- round(rendimiento, 3)
Li <- round(Li, 3)
Ls <- round(Ls, 3)
MC <- (Li + Ls) / 2
ni <- numeric(length(Li))
for (i in 1:length(Li)) {
if (i < length(Li)) {
ni[i] <- sum(rendimiento >= Li[i] & rendimiento < Ls[i])
} else {
ni[i] <- sum(rendimiento >= Li[i] & rendimiento <= Ls[i])
}
}
hi <- (ni / n) * 100
Ni_asc <- cumsum(ni)
Ni_desc <- rev(cumsum(rev(ni)))
Hi_asc <- cumsum(hi)
Hi_desc <- rev(cumsum(rev(hi)))
Intervalo <- paste0("[", round(Li, 2), " - ", round(Ls, 2), ")")
Intervalo[length(Intervalo)] <- paste0(
"[",
round(Li[length(Li)], 2),
" - ",
round(Ls[length(Ls)], 2),
"]"
)
TDF_rendimiento <- data.frame(
Intervalo = Intervalo,
MC = round(MC, 2),
ni = ni,
hi = round(hi, 2),
Ni_ascendente = Ni_asc,
Ni_descendente = Ni_desc,
Hi_ascendente = round(Hi_asc, 2),
Hi_descendente = round(Hi_desc, 2)
)
totales <- data.frame(
Intervalo = "Totales",
MC = "-",
ni = sum(ni),
hi = round(sum(hi), 2),
Ni_ascendente = "-",
Ni_descendente = "-",
Hi_ascendente = "-",
Hi_descendente = "-"
)
TDF_rendimiento_completa <- rbind(TDF_rendimiento, totales)
TDF_rendimiento_completa %>%
gt() %>%
tab_header(
title = "Tabla Nro. 1",
subtitle = "Distribución de frecuencia del rendimiento (tallos/ha) en fincas florícolas de Cayambe"
) %>%
tab_source_note(
source_note = md("Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza <br> Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha)")
) %>%
tab_style(
style = cell_borders(sides = "left", color = "black", weight = px(2)),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(sides = "right", color = "black", weight = px(2)),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(sides = "left", color = "black", weight = px(2)),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_borders(sides = "right", color = "black", weight = px(2)),
locations = cells_column_labels()
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
row.striping.include_table_body = TRUE,
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
)
| Tabla Nro. 1 | |||||||
| Distribución de frecuencia del rendimiento (tallos/ha) en fincas florícolas de Cayambe | |||||||
| Intervalo | MC | ni | hi | Ni_ascendente | Ni_descendente | Hi_ascendente | Hi_descendente |
|---|---|---|---|---|---|---|---|
| [1120 - 1595) | 1357.5 | 8 | 8 | 8 | 100 | 8 | 100 |
| [1595 - 2070) | 1832.5 | 11 | 11 | 19 | 92 | 19 | 92 |
| [2070 - 2545) | 2307.5 | 18 | 18 | 37 | 81 | 37 | 81 |
| [2545 - 3020) | 2782.5 | 25 | 25 | 62 | 63 | 62 | 63 |
| [3020 - 3495) | 3257.5 | 19 | 19 | 81 | 38 | 81 | 38 |
| [3495 - 3970) | 3732.5 | 12 | 12 | 93 | 19 | 93 | 19 |
| [3970 - 4445) | 4207.5 | 4 | 4 | 97 | 7 | 97 | 7 |
| [4445 - 4920] | 4682.5 | 3 | 3 | 100 | 3 | 100 | 3 |
| Totales | - | 100 | 100 | - | - | - | - |
| Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha) |
|||||||
lim_inf <- floor(min_rend / 500) * 500
lim_sup <- ceiling(max_rend / 500) * 500
A2 <- 500
Li2 <- seq(from = lim_inf, to = lim_sup - A2, by = A2)
Ls2 <- Li2 + A2
MC2 <- (Li2 + Ls2) / 2
ni2 <- numeric(length(Li2))
for (i in 1:length(Li2)) {
if (i < length(Li2)) {
ni2[i] <- sum(rendimiento >= Li2[i] & rendimiento < Ls2[i])
} else {
ni2[i] <- sum(rendimiento >= Li2[i] & rendimiento <= Ls2[i])
}
}
hi2 <- (ni2 / n) * 100
Ni2_asc <- cumsum(ni2)
Ni2_desc <- rev(cumsum(rev(ni2)))
Hi2_asc <- cumsum(hi2)
Hi2_desc <- rev(cumsum(rev(hi2)))
Intervalo2 <- paste0("[", Li2, " - ", Ls2, ")")
Intervalo2[length(Intervalo2)] <- paste0(
"[",
Li2[length(Li2)],
" - ",
Ls2[length(Ls2)],
"]"
)
TDF_rend_10 <- data.frame(
Intervalo = Intervalo2,
MC = MC2,
ni = ni2,
hi = round(hi2, 2),
Ni_ascendente = Ni2_asc,
Ni_descendente = Ni2_desc,
Hi_ascendente = round(Hi2_asc, 2),
Hi_descendente = round(Hi2_desc, 2)
)
totales2 <- data.frame(
Intervalo = "Totales",
MC = "-",
ni = sum(ni2),
hi = round(sum(hi2), 2),
Ni_ascendente = "-",
Ni_descendente = "-",
Hi_ascendente = "-",
Hi_descendente = "-"
)
TDF_rend_10_completa <- rbind(TDF_rend_10, totales2)
TDF_rend_10_completa %>%
gt() %>%
tab_header(
title = "Tabla Nro. 2",
subtitle = "Distribución de frecuencia reducida del rendimiento (intervalos de 500 tallos/ha)"
) %>%
tab_source_note(
source_note = md("Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza <br> Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha)")
) %>%
tab_style(
style = cell_borders(sides = "left", color = "black", weight = px(2)),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(sides = "right", color = "black", weight = px(2)),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(sides = "left", color = "black", weight = px(2)),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_borders(sides = "right", color = "black", weight = px(2)),
locations = cells_column_labels()
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
row.striping.include_table_body = TRUE,
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
)
| Tabla Nro. 2 | |||||||
| Distribución de frecuencia reducida del rendimiento (intervalos de 500 tallos/ha) | |||||||
| Intervalo | MC | ni | hi | Ni_ascendente | Ni_descendente | Hi_ascendente | Hi_descendente |
|---|---|---|---|---|---|---|---|
| [1000 - 1500) | 1250 | 6 | 6 | 6 | 100 | 6 | 100 |
| [1500 - 2000) | 1750 | 11 | 11 | 17 | 94 | 17 | 94 |
| [2000 - 2500) | 2250 | 18 | 18 | 35 | 83 | 35 | 83 |
| [2500 - 3000) | 2750 | 26 | 26 | 61 | 65 | 61 | 65 |
| [3000 - 3500) | 3250 | 21 | 21 | 82 | 39 | 82 | 39 |
| [3500 - 4000) | 3750 | 12 | 12 | 94 | 18 | 94 | 18 |
| [4000 - 4500) | 4250 | 4 | 4 | 98 | 6 | 98 | 6 |
| [4500 - 5000] | 4750 | 2 | 2 | 100 | 2 | 100 | 2 |
| Totales | - | 100 | 100 | - | - | - | - |
| Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha) |
|||||||
Histograma_rend <- hist(rendimiento, breaks = k_detallado, plot = FALSE)
hist(rendimiento, breaks = k_detallado,
main = "Grafica Nro.1 de distribución de frecuencias del rendimiento en fincas de Cayambe",
xlab = "Rendimiento (tallos/ha)",
ylab = "Cantidad",
ylim = c(0, max(Histograma_rend$counts)),
col = "darkseagreen3",
cex.main = 0.9,
cex.lab = 1,
cex.axis = 0.9,
xaxt = "n")
axis(1, at = Histograma_rend$breaks,
labels = round(Histograma_rend$breaks, 0), las = 1,
cex.axis = 0.85)
grid()
Histograma_rend <- hist(rendimiento, breaks = k_detallado, plot = FALSE)
par(mgp = c(3.2, 1, 0))
hist(rendimiento, breaks = k_detallado,
main = "Grafica Nro.2 de distribución de frecuencias del rendimiento en fincas de Cayambe",
xlab = "Rendimiento (tallos/ha)",
ylab = "Cantidad",
ylim = c(0, max(Histograma_rend$counts) * 1.1),
col = "darkseagreen3",
cex.main = 0.9,
cex.lab = 1,
cex.axis = 0.9,
xaxt = "n")
axis(1,
at = Histograma_rend$breaks,
labels = round(Histograma_rend$breaks, 0),
las = 1,
cex.axis = 0.85)
grid()
## 5.2.- Histogramas Porcentuales
bp <- barplot(hi2,
space = 0,
names.arg = FALSE,
xaxt = "n",
main = "Grafica Nro.3 de distribución porcentual del rendimiento en fincas de Cayambe",
xlab = "Rendimiento (tallos/ha)",
ylab = "Porcentaje (%)",
col = "darkseagreen3",
border = "black",
ylim = c(0, max(hi2) + 5),
cex.main = 0.9,
cex.lab = 1,
cex.axis = 0.9)
bordes <- c(bp[1] - 0.5, bp + 0.5)
axis(1,
at = bordes,
labels = c(Li2, tail(Ls2, 1)),
las = 2,
cex.axis = 0.8,
tck = -0.03)
grid()
bp <- barplot(hi2,
space = 0,
names.arg = FALSE,
xaxt = "n",
yaxt = "n",
main = "Grafica Nro.4 de distribución porcentual del rendimiento en fincas de Cayambe",
xlab = "Rendimiento (tallos/ha)",
ylab = "Porcentaje (%)",
col = "darkseagreen3",
border = "black",
ylim = c(0, 100),
cex.main = 0.9,
cex.lab = 1,
cex.axis = 0.9)
bordes <- c(bp[1] - 0.5, bp + 0.5)
axis(1,
at = bordes,
labels = c(Li2, tail(Ls2, 1)),
las = 2,
cex.axis = 0.8,
tck = -0.03)
axis(2,
at = seq(0, 100, by = 20),
labels = paste0(seq(0, 100, by = 20)),
las = 1)
grid()
# Diagrama de caja y bigotes general
op <- par(no.readonly = TRUE)
on.exit(par(op))
h_dens <- hist(rendimiento, breaks = k_detallado, plot = FALSE)
y_top <- max(h_dens$density) * 1.15
par(mgp = c(3.5, 1, 0))
hist(rendimiento,
breaks = k_detallado,
freq = FALSE,
main = "Grafica Nro.5: Histograma de densidad y diagrama de caja del rendimiento en Cayambe",
xlab = "Rendimiento (tallos/ha)",
ylab = "Densidad",
ylim = c(0, y_top),
xlim = c(lim_inf, lim_sup),
col = "white",
border = "black",
cex.main = 0.9,
cex.lab = 1,
cex.axis = 0.9,
xaxt = "n")
axis(1,
at = seq(lim_inf, lim_sup, by = 500),
labels = seq(lim_inf, lim_sup, by = 500),
las = 1,
cex.axis = 0.85)
q <- quantile(rendimiento, probs = c(0.25, 0.50, 0.75), na.rm = TRUE)
ric <- q[3] - q[1]
big_inf <- max(min(rendimiento, na.rm = TRUE), q[1] - 1.5 * ric)
big_sup <- min(max(rendimiento, na.rm = TRUE), q[3] + 1.5 * ric)
y_mid <- y_top * 0.48
alto_c <- y_top * 0.14
alto_b <- y_top * 0.06
segments(x0 = c(big_inf, q[3]), y0 = y_mid,
x1 = c(q[1], big_sup), y1 = y_mid,
lty = 2, lwd = 1.2, col = "black")
segments(x0 = c(big_inf, big_sup), y0 = y_mid - alto_b,
x1 = c(big_inf, big_sup), y1 = y_mid + alto_b,
lwd = 1.2, col = "black")
rect(xleft = q[1], ybottom = y_mid - alto_c,
xright = q[3], ytop = y_mid + alto_c,
col = "grey", border = "black", lwd = 1.3)
segments(x0 = q[2], y0 = y_mid - alto_c,
x1 = q[2], y1 = y_mid + alto_c,
lwd = 2.8, col = "black")
plot(Ls2, Ni2_asc,
type = "b",
pch = 16,
col = "turquoise3",
lwd = 1,
ylim = c(0, n),
xlim = c(min(Ls2), max(Ls2)),
xaxt = "n",
xlab = "Rendimiento (tallos/ha)",
ylab = "Cantidad",
main = "Gráfica N°6: Ojiva ascendente y descendente del rendimiento en Cayambe",
cex.main = 1)
axis(1, at = Ls2, las = 2, cex.axis = 0.8)
lines(Ls2, Ni2_desc,
type = "b",
pch = 16,
col = "black",
lwd = 1)
grid()
box()
plot(Ls2, Hi2_asc,
type = "b",
pch = 16,
col = "turquoise3",
lwd = 1,
ylim = c(0, 100),
xlim = c(min(Ls2), max(Ls2)),
xaxt = "n",
xlab = "Rendimiento (tallos/ha)",
ylab = "Porcentaje (%)",
main = "Gráfica N°7: Ojiva porcentual ascendente y descendente del rendimiento en Cayambe",
cex.main = 1)
axis(1, at = Ls2, las = 2, cex.axis = 0.8)
lines(Ls2, Hi2_desc,
type = "b",
pch = 16,
col = "black",
lwd = 1)
grid()
box()
X <- mean(rendimiento, na.rm = TRUE)
Me <- median(rendimiento, na.rm = TRUE)
moda_index <- which.max(TDF_rend_10_completa$ni[1:(nrow(TDF_rend_10_completa) - 1)])
Mo <- TDF_rend_10_completa$Intervalo[moda_index]
desv <- sd(rendimiento, na.rm = TRUE)
CV <- (desv / X) * 100
m_rend <- mean(rendimiento, na.rm = TRUE)
s_rend <- sd(rendimiento, na.rm = TRUE)
n_rend <- length(rendimiento)
As <- (sum((rendimiento - m_rend)^3) / n_rend) / (s_rend^3)
K <- (sum((rendimiento - m_rend)^4) / n_rend) / (s_rend^4) - 3
Tabla_indicadores <- data.frame(
Variable = "rendimiento_tallos_ha",
Rango = paste0("[", round(min(rendimiento), 2), " - ", round(max(rendimiento), 2), "]"),
Media = X,
Mediana = Me,
Moda = Mo,
DesvEst = desv,
CV = CV,
Asimetria = As,
Curtosis = K
)
Tabla_indicadores %>%
gt() %>%
cols_label(
Variable = "Variable",
Rango = "Rango",
Media = "Media (X)",
Mediana = "Mediana (Me)",
Moda = "Moda (Mo)",
DesvEst = "Desv. Est. (sd)",
CV = "CV (%)",
Asimetria = "Asimetria (As)",
Curtosis = "Curtosis (K)"
) %>%
tab_header(
title = "Tabla Nro. 3",
subtitle = "Indicadores Estadisticos del rendimiento en fincas florícolas de Cayambe"
) %>%
tab_source_note(
source_note = "Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza | Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha)"
) %>%
tab_spanner(
label = "Tendencia Central",
columns = c(Media, Mediana, Moda)
) %>%
tab_spanner(
label = "Dispersion",
columns = c(DesvEst, CV)
) %>%
tab_spanner(
label = "Forma",
columns = c(Asimetria, Curtosis)
) %>%
fmt_number(
columns = c(Media, Mediana, DesvEst, CV, Asimetria, Curtosis),
decimals = 2
) %>%
tab_style(
style = cell_borders(
sides = c("left", "right", "top", "bottom"),
color = "black",
weight = px(1)
),
locations = list(
cells_body(columns = everything(), rows = everything()),
cells_column_labels(columns = everything()),
cells_column_spanners(spanners = everything())
)
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.left.color = "black",
table.border.right.color = "black",
table_body.hlines.color = "black",
table_body.vlines.color = "black",
column_labels.border.bottom.width = px(2)
)
| Tabla Nro. 3 | ||||||||
| Indicadores Estadisticos del rendimiento en fincas florícolas de Cayambe | ||||||||
| Variable | Rango |
Tendencia Central
|
Dispersion
|
Forma
|
||||
|---|---|---|---|---|---|---|---|---|
| Media (X) | Mediana (Me) | Moda (Mo) | Desv. Est. (sd) | CV (%) | Asimetria (As) | Curtosis (K) | ||
| rendimiento_tallos_ha | [1120 - 4920] | 2,810.65 | 2,810.00 | [2500 - 3000) | 804.19 | 28.61 | 0.11 | −0.35 |
| Elaborado por: Nahomi Chimbo, Cristina Fuel, Blanca Guatemal, Dayanara Lopez, Melany Tuza | Fuente: floricultura_cayambe_100.csv (variable rendimiento_tallos_ha) | ||||||||
La variable rendimiento por hectárea fluctúa entre 1120 tallos/ha y 4920 tallos/ha y su valor representativo gira en torno a 2810.65 tallos/ha (Media, ante leve asimetría positiva de \(0.11\) y sin presencia de valores atípicos en el diagrama de caja), siendo un conjunto de valores moderadamente dispersos o heterogéneos (\(CV = 28.61\%\)), donde la concentración de datos es mayor en la franja central de la variable (26.00% en el intervalo modal [2500 - 3000) tallos/ha, y 44.00% entre 2000 y 3000 tallos/ha) y sin presencia de valores atípicos. Bajo nuestro criterio, este comportamiento es estable y favorable para la producción florícola en Cayambe porque la distribución es bastante equilibrada y simétrica alrededor de los 2,810 tallos/ha sin extremos atípicos severos, aunque la dispersión del 28.61% refleja diferencias de manejo agronómico, variedad o condiciones de lote entre fincas.