|
1 | | - |
2 | 1 | --- |
3 | 2 | title: "MEL Dashboard Summary" |
4 | 3 | format: html |
5 | 4 | editor: visual |
6 | 5 | --- |
7 | 6 |
|
8 | | -```{r setup} |
| 7 | +```{r} |
| 8 | +# Load required libraries |
9 | 9 | library(tidyverse) |
10 | | -source("scripts/mel_reshape.R") |
11 | | -``` |
12 | 10 |
|
13 | | -## 📥 Load MEL Indicator Data |
14 | | - |
15 | | -```{r} |
16 | | -df <- read.csv("sample_data/mel_indicators_wide.csv") |
17 | | -head(df) |
18 | | -``` |
| 11 | +# Sample input (replace with real data or read.csv) |
| 12 | +df <- data.frame( |
| 13 | + Indicator = c("Coverage", "Access", "Retention"), |
| 14 | + DistrictA = c(0.82, 0.76, 0.91), |
| 15 | + DistrictB = c(0.67, 0.71, 0.85) |
| 16 | +) |
19 | 17 |
|
20 | | ---- |
| 18 | +# Reshape for dashboard |
| 19 | +df_long <- df %>% |
| 20 | + pivot_longer(-Indicator, names_to = "District", values_to = "Score") |
21 | 21 |
|
22 | | -## 🔄 Reshape to Dashboard Format |
| 22 | +# Save as dashboard-ready CSV |
| 23 | +write.csv(df_long, "dashboard_export.csv", row.names = FALSE) |
23 | 24 |
|
24 | | -```{r} |
25 | | -df_long <- reshape_indicators(df) |
| 25 | +# Display preview table |
26 | 26 | head(df_long) |
27 | 27 | ``` |
28 | | - |
29 | | ---- |
30 | | - |
31 | | -## 📤 Export for Looker Studio or Power BI |
32 | | - |
33 | | -```{r} |
34 | | -write.csv(df_long, "outputs/mel_indicators_long.csv", row.names = FALSE) |
35 | | -``` |
36 | | - |
37 | | ---- |
38 | | - |
39 | | -## 📊 Visual Check |
40 | | - |
41 | | -```{r} |
42 | | -ggplot(df_long, aes(x = quarter, y = value, fill = indicator)) + |
43 | | - geom_col(position = "dodge") + |
44 | | - facet_wrap(~ program) + |
45 | | - labs(title = "Dashboard-Ready MEL Indicators") + |
46 | | - theme_minimal() |
47 | | -``` |
0 commit comments