Include

Para compilar el RMardown con formato instalar también: prettydoc.

library(ggplot2)
library(tidyr)
library(dplyr)

Global KPI (pondered)

# Crear un dataframe con datos
datos <- data.frame(
  Fecha = c("202401", "202402", "202401", "202402", "202401", "202402"),
  Total = c(79.1, 88.9, 83.6, 85.2, 88.2, 83.7),
  CEI = c(77.7, 89.5, 91.2, 78.4, 31.0, 44.3),
  CON = c(88.2, 85.2, 43.0, 44.3, 83.6, 78.4)
)
# Convertir los datos a un formato largo
datos_long <- pivot_longer(datos, cols = Total:CON, names_to = "Categoría", values_to = "Valor")

# Crear la gráfica
ggplot(datos_long, aes(x = Fecha, y = Valor, fill = Categoría)) +
  geom_bar(stat = "identity", position = position_dodge(), width = 0.7) +
  theme_minimal() +
  labs(x = "Fecha", y = "Porcentaje (%)", title = "Global KPI (pondered)", fill = "Categoría") +
  scale_fill_brewer(palette = "Pastel1")  # Usar una paleta de colores para mejorar la visualización