Summary

Row

Total Registrants

61

Attending Drinks

41

Attending Dinner

49

On Waiting List (either event)

7

Invited Speakers

4

Organizers

10

Row

Universities

Research Areas

Attendance & Food

Row

Event Attendance

Drinks × Dinner Cross-tab

Row

Dietary Requirements

Lunch Choices

---
title: "TCUOE Conference — Registration Dashboard"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    theme: flatly
    source_code: embed
params:
  data_path: "participant_data.csv"
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)

df <- read_csv(params$data_path, show_col_types = FALSE)
n_total <- nrow(df)

pal <- c("#2E86AB", "#A23B72", "#F18F01", "#C73E1D", "#3B1F2B",
         "#44BBA4", "#E94F37", "#393E41", "#84BCDA", "#6B4226", "#7B2D8B", "#5C8001")

th <- theme_minimal(base_size = 13) +
  theme(
    plot.title       = element_text(face = "bold", size = 13),
    plot.subtitle    = element_text(color = "grey40", size = 10),
    panel.grid.minor = element_blank(),
    axis.text        = element_text(size = 10)
  )
```

Summary
=======================================================================

Row
-----------------------------------------------------------------------

### Total Registrants

```{r}
valueBox(n_total, icon = "fa-users", color = "#2E86AB")
```

### Attending Drinks

```{r}
valueBox(sum(df$drinks == "Yes", na.rm = TRUE), icon = "fa-glass-martini", color = "#44BBA4")
```

### Attending Dinner

```{r}
valueBox(sum(df$dinner == "Yes", na.rm = TRUE), icon = "fa-utensils", color = "#A23B72")
```

### On Waiting List (either event)

```{r}
valueBox(
  sum(df$drinks == "Waiting list" | df$dinner == "Waiting list", na.rm = TRUE),
  icon = "fa-clock", color = "#F18F01"
)
```

### Invited Speakers

```{r}
valueBox(sum(df$type == "Invited Speaker", na.rm = TRUE), icon = "fa-microphone", color = "#A23B72")
```

### Organizers

```{r}
valueBox(sum(df$type == "Organizer", na.rm = TRUE), icon = "fa-star", color = "#6B4226")
```

Row
-----------------------------------------------------------------------

### Universities

```{r}
p <- df %>%
  count(university, sort = TRUE) %>%
  mutate(university = fct_reorder(university, n)) %>%
  ggplot(aes(n, university, fill = university, text = paste0(university, ": ", n))) +
  geom_col(show.legend = FALSE) +
  scale_fill_manual(values = colorRampPalette(pal)(n_distinct(df$university))) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = "Count", y = NULL) +
  th
ggplotly(p, tooltip = "text")
```

### Research Areas

```{r}
areas_long <- df %>%
  select(id, research_area) %>%
  mutate(research_area = str_split(research_area, ";")) %>%
  unnest(research_area) %>%
  mutate(research_area = str_trim(research_area)) %>%
  filter(research_area != "")

p <- areas_long %>%
  count(research_area, sort = TRUE) %>%
  mutate(research_area = fct_reorder(research_area, n)) %>%
  ggplot(aes(n, research_area, fill = research_area, text = paste0(research_area, ": ", n))) +
  geom_col(show.legend = FALSE) +
  scale_fill_manual(values = colorRampPalette(pal)(n_distinct(areas_long$research_area))) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = "Count", y = NULL) +
  th
ggplotly(p, tooltip = "text")
```

Attendance & Food
=======================================================================

Row
-----------------------------------------------------------------------

### Event Attendance

```{r}
att_df <- bind_rows(
  df %>% count(response = drinks) %>% mutate(event = "Networking Drinks (26 Mar)"),
  df %>% count(response = dinner) %>% mutate(event = "Conference Dinner (27 Mar)")
)

p <- att_df %>%
  ggplot(aes(response, n, fill = response, text = paste0(response, ": ", n))) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~event) +
  scale_fill_manual(values = c("Yes" = "#2E86AB", "No" = "#C73E1D", "Waiting list" = "#F18F01")) +
  scale_y_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = NULL, y = "Count") +
  th
ggplotly(p, tooltip = "text")
```

### Drinks × Dinner Cross-tab

```{r}
p <- df %>%
  count(drinks, dinner) %>%
  complete(
    drinks = c("Yes", "Waiting list", "No"),
    dinner = c("Yes", "Waiting list", "No"),
    fill   = list(n = 0)
  ) %>%
  mutate(
    drinks = factor(drinks, levels = c("Yes", "Waiting list", "No")),
    dinner = factor(dinner, levels = c("Yes", "Waiting list", "No"))
  ) %>%
  ggplot(aes(dinner, drinks, fill = n, text = paste0("Drinks: ", drinks, "<br>Dinner: ", dinner, "<br>n: ", n))) +
  geom_tile(color = "white", linewidth = 1.5) +
  geom_text(aes(label = n), size = 6, fontface = "bold") +
  scale_fill_gradient(low = "#84BCDA", high = "#2E86AB") +
  scale_x_discrete(position = "top") +
  labs(x = "Conference Dinner (27 Mar)", y = "Networking Drinks (26 Mar)") +
  th + theme(legend.position = "none")
ggplotly(p, tooltip = "text")
```

Row
-----------------------------------------------------------------------

### Dietary Requirements

```{r}
p <- df %>%
  count(dietary, sort = TRUE) %>%
  mutate(dietary = fct_reorder(dietary, n)) %>%
  ggplot(aes(n, dietary, fill = dietary, text = paste0(dietary, ": ", n))) +
  geom_col(show.legend = FALSE) +
  scale_fill_manual(values = colorRampPalette(pal)(n_distinct(df$dietary))) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = "Count", y = NULL) +
  th
ggplotly(p, tooltip = "text")
```

### Lunch Choices

```{r}
p <- df %>%
  count(lunch_short, sort = TRUE) %>%
  mutate(lunch_short = fct_reorder(lunch_short, n)) %>%
  ggplot(aes(n, lunch_short, fill = lunch_short, text = paste0(lunch_short, ": ", n))) +
  geom_col(show.legend = FALSE) +
  scale_fill_manual(values = colorRampPalette(pal)(n_distinct(df$lunch_short))) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = "Count", y = NULL) +
  th
ggplotly(p, tooltip = "text")
```

Participants & Consent
=======================================================================

Row
-----------------------------------------------------------------------

### Programme Type

```{r}
p <- df %>%
  mutate(programme_type = case_when(
    str_detect(institution, regex("CDT|Centre for Doctoral Training", ignore_case = TRUE)) ~ "CDT",
    str_detect(institution, regex("DTP|Doctoral Training Partnership", ignore_case = TRUE)) ~ "DTP",
    is.na(institution) | str_trim(institution) == "" ~ "Not specified",
    TRUE ~ "Other"
  )) %>%
  count(programme_type, sort = TRUE) %>%
  ggplot(aes(programme_type, n, fill = programme_type, text = paste0(programme_type, ": ", n))) +
  geom_col(show.legend = FALSE, width = 0.6) +
  scale_fill_manual(values = c("CDT" = "#2E86AB", "DTP" = "#A23B72",
                               "Other" = "#F18F01", "Not specified" = "#888888")) +
  scale_y_continuous(expand = expansion(mult = c(0, 0.2))) +
  labs(x = NULL, y = "Count") +
  th
ggplotly(p, tooltip = "text")
```

### Consent

```{r}
consent_df <- bind_rows(
  df %>% count(response = photo_consent) %>% mutate(type = "Photography"),
  df %>% count(response = comms_consent) %>% mutate(type = "Communications")
)

p <- consent_df %>%
  ggplot(aes(response, n, fill = response, text = paste0(response, ": ", n))) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~type) +
  scale_fill_manual(values = c("Consents" = "#2E86AB", "Does not consent" = "#C73E1D")) +
  scale_y_continuous(expand = expansion(mult = c(0, 0.15))) +
  labs(x = NULL, y = "Count") +
  th
ggplotly(p, tooltip = "text")
```