title: “Sacrificio de ganado bovino en el Valle del Cauca”
output: flexdashboard::flex_dashboard: orientation: rows social: menu source_code: embed
author: | Isabela Caro Díaz , Angela Nicol Botina , Sara Velásquez Rodríguez, Sarah Valencia González , Jaime Andrés Guevara
date: “2025-11-29”
Municipio Machos.Sacrificados Promedio.en.Kg.Machos
Length:85 Min. : 43 Min. :313.0
Class :character 1st Qu.: 396 1st Qu.:393.0
Mode :character Median : 1066 Median :420.0
Mean : 2049 Mean :421.7
3rd Qu.: 2485 3rd Qu.:450.0
Max. :29371 Max. :513.0
Hembras.Sacrificadas Promedio.en.Kg.Hembras Animales.Sacrificados
Min. : 35 Min. :298.0 Min. : 102
1st Qu.: 276 1st Qu.:363.0 1st Qu.: 672
Median : 595 Median :382.0 Median : 1685
Mean : 1128 Mean :381.9 Mean : 3177
3rd Qu.: 1299 3rd Qu.:400.0 3rd Qu.: 3820
Max. :18223 Max. :551.0 Max. :47594
Peso.en.pie.en.Tn Año
Min. : 33 Length:85
1st Qu.: 282 Class :character
Median : 699 Mode :character
Mean : 1311
3rd Qu.: 1585
Max. :20119
Variable Media Mediana Moda Varianza
Machos.Sacrificados Machos.Sacrificados 2049.141 1066 1822 12425727
Hembras.Sacrificadas Hembras.Sacrificadas 1128.094 595 953 4430193
Animales.Sacrificados Animales.Sacrificados 3177.235 1685 2775 31559000
Peso.en.pie.en.Tn Peso.en.pie.en.Tn 1311.424 699 699 5614424
Desv_Estandar
Machos.Sacrificados 3525.014
Hembras.Sacrificadas 2104.802
Animales.Sacrificados 5617.740
Peso.en.pie.en.Tn 2369.478
[1] 0.9908458
Pearson's product-moment correlation
data: Machos and Hembras
t = 66.867, df = 83, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.9859218 0.9940527
sample estimates:
cor
0.9908458
---
title: "Sacrificio de ganado bovino en el Valle del Cauca"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
author: |
Isabela Caro Díaz , Angela Nicol Botina , Sara Velásquez Rodríguez, Sarah Valencia González , Jaime Andrés Guevara
date: "2025-11-29"
---
Datos
======================================================================================================================================
Row
-------------------------------------------------------------------
```{r, fig.width=5, fig.height=5}
library(tidyverse)
library(ggplot2)
library(readr)
library(readxl)
library(PerformanceAnalytics)
library(forecast)
library(flexdashboard)
library(kableExtra)
df <- read_excel("Sacrificio_De_Ganado_Bovino_en_el_valle_del_cauca_20250926.xlsx")
names(df) <- make.names(names(df))
summary (df)
```
### Fuente de datos
```{r tabla-descriptiva}
### Resumen estadisticas descriptivas
get_mode <- function(v) {
uniques <- unique(v)
uniques[which.max(tabulate(match(v, uniques)))]
}
variables <- data.frame(
Machos.Sacrificados = df$Machos.Sacrificados,
Hembras.Sacrificadas = df$Hembras.Sacrificadas,
Animales.Sacrificados = df$Animales.Sacrificados,
Peso.en.pie.en.Tn = df$Peso.en.pie.en.Tn
)
tabla_stats <- data.frame(
Variable = colnames(variables),
Media = sapply(variables, mean, na.rm = TRUE),
Mediana = sapply(variables, median, na.rm = TRUE),
Moda = sapply(variables, get_mode),
Varianza = sapply(variables, var, na.rm = TRUE),
Desv_Estandar = sapply(variables, sd, na.rm = TRUE)
)
tabla_stats
```
Boxplot
===================================================================
Row
-------------------------------------------------------------------
```{r, fig.width=6, fig.height=6}
boxplot(df$Machos.Sacrificados, col="skyblue", main="Machos Sacrificados",
ylim=c(0, 10000))
```{r, fig.width=6, fig.height=6}
boxplot(df$Hembras.Sacrificadas, col ="pink",main="Hembras Sacrificadas",
ylim=c(0,4000))
```
Row
-------------------------------------------------------------------
```{r, fig.width=6, fig.height=6}
boxplot(df$Animales.Sacrificados, col="lightgreen",main="Animales sacrificados",
ylim=c(0,12000))
```{r, fig.width=6, fig.height=6}
boxplot(df$Peso.en.pie.en.Tn, col="orange",main="Peso en pie en Tn",
ylim=c(0,5000))
par(mfrow=c(1,1)) # volver a 1 gráfico
```
Row
-------------------------------------------------------------------
Histogramas
===================================================================
Row
-------------------------------------------------------------------
```{r, fig.width=6, fig.height=6}
media_machos <- mean(df$Machos.Sacrificados, na.rm = TRUE)
mediana_machos <- median(df$Machos.Sacrificados, na.rm = TRUE)
moda_machos <- get_mode(df$Machos.Sacrificados)
hist(df$Machos.Sacrificados, col = "skyblue",
main = "Histograma Machos Sacrificados con Media, Mediana y Moda",
xlab = "Machos Sacrificados")
abline(v = media_machos, col = "red", lwd = 2, lty = 1)
abline(v = mediana_machos, col = "green", lwd = 2, lty = 2)
abline(v = moda_machos, col = "blue", lwd = 2, lty = 3)
legend("topright",
legend = c("Media", "Mediana", "Moda"),
col = c("red", "green", "blue"),
lwd = 2,
lty = c(1, 2, 3))
```{r, fig.width=6, fig.height=6}
# Histogramas para Hembras Sacrificadas
media_hembras <- mean(df$Hembras.Sacrificadas, na.rm = TRUE)
mediana_hembras <- median(df$Hembras.Sacrificadas, na.rm = TRUE)
moda_hembras <- get_mode(df$Hembras.Sacrificadas)
hist(df$Hembras.Sacrificadas, col = "gray",
main = "Histograma Hembras Sacrificadas con Media, Mediana y Moda",
xlab = "Hembras Sacrificadas")
abline(v = media_hembras, col = "red", lwd = 2, lty = 1)
abline(v = mediana_hembras, col = "green", lwd = 2, lty = 2)
abline(v = moda_hembras, col = "blue", lwd = 2, lty = 3)
legend("topright",
legend = c("Media", "Mediana", "Moda"),
col = c("red", "green", "blue"),
lwd = 2,
lty = c(1, 2, 3))
```
Row
-------------------------------------------------------------------
```{r, fig.width=6, fig.height=6}
# Histograma para Peso en pie en Tn
media_peso <- mean(df$Peso.en.pie.en.Tn, na.rm = TRUE)
mediana_peso <- median(df$Peso.en.pie.en.Tn, na.rm = TRUE)
moda_peso <- get_mode(df$Peso.en.pie.en.Tn)
hist(df$Peso.en.pie.en.Tn, col = "orange",
main = "Histograma Peso en pie en Tn con Media, Mediana y Moda",
xlab = "Peso en pie en Tn")
abline(v = media_peso, col = "red", lwd = 2, lty = 1)
abline(v = mediana_peso, col = "green", lwd = 2, lty = 2)
abline(v = moda_peso, col = "blue", lwd = 2, lty = 3)
legend("topright",
legend = c("Media", "Mediana", "Moda"),
col = c("red", "green", "blue"),
lwd = 2,
lty = c(1, 2, 3))
```
Row
-------------------------------------------------------------------
Dispersión
===================================================================
Row
-------------------------------------------------------------------
```{r, fig.width=5, fig.height=5}
plot(df$Machos.Sacrificados, df$Hembras.Sacrificadas, col="blue",
main="Dispersión Machos vs Hembras",
xlab="Machos Sacrificados", ylab="Hembras Sacrificadas", xlim =c(0,10000))
```{r, fig.width=5, fig.height=5}
plot(df$Animales.Sacrificados, df$Peso.en.pie.en.Tn, col="red",
main="Dispersión Animales vs Peso en pie",
xlab="Animales Sacrificados", ylab="Peso en pie en Tn", xlim =c(0,15000))
```
Row
-------------------------------------------------------------------
Correlación
===================================================================
Row
-------------------------------------------------------------------
```{r, fig.width=5, fig.height=5}
#Declarar las variables a comparar
Machos<-c(df$Machos.Sacrificados)
Hembras<-c(df$Hembras.Sacrificadas)
#Determinar la correlación entre ellas
cor(Machos,Hembras)
cor.test(Machos,Hembras)
#Graficar
pairs(Machos~Hembras)
```
```{r, fig.width=5, fig.height=5}
#Matriz de correlación
data <-data.frame(Machos,Hembras)
chart.Correlation(data)
```
Row
-------------------------------------------------------------------
Comparación por municipio
===================================================================
Row
-------------------------------------------------------------------
```{r}
##Declarar variable cualitativa y cuantitativa
Cualitativa<- c(df$Municipio)
Cuantitativa<-c(df$Animales.Sacrificados)
#Diagrama de cajas
boxplot(Cuantitativa~Cualitativa)
```
Row
-------------------------------------------------------------------
Pronóstico
===================================================================
Row
-------------------------------------------------------------------
```{r}
serie <- ts(df$Animales.Sacrificados, start = min(df$Año), frequency = 1)
autoplot(serie) +
labs(title = "Pronóstico en el tiempo",
x = "Año",
y = "Animales Sacrificados") +
theme_bw()
```
Row
-------------------------------------------------------------------