1 Data import check

import_types <- tibble(
  ColumnName = names(survey_default),
  GuessedByReadr = map_chr(survey_default, ~ class(.x)[1]),
  AfterManualParsing = map_chr(data, ~ class(.x)[1])
) %>%
  mutate(Changed = if_else(GuessedByReadr != AfterManualParsing, "Yes", ""))

datatable(import_types, rownames = FALSE, options = list(dom = "t", pageLength = 27))
datatable(prob_raw, rownames = FALSE, options = list(dom = "tp", pageLength = 5))

2 Data overview

paste("Number of rows:", nrow(data))
## [1] "Number of rows: 90"
paste("Number of columns:", ncol(data))
## [1] "Number of columns: 27"
# Helper function to extract top 3 most frequent values separated by " | "
get_top_values <- function(x) {
  x_clean <- na.omit(as.character(x))
  if (length(x_clean) == 0) return("")
  top3 <- names(sort(table(x_clean), decreasing = TRUE))[1:min(3, length(unique(x_clean)))]
  paste(top3, collapse = " | ")
}

# Build column-by-column summary dataframe
overview_df <- tibble(
  ColumnName     = names(data),
  DataType       = map_chr(data, ~ class(.x)[1]),
  UniqueValues   = map_int(data, ~ n_distinct(.x, na.rm = TRUE)),
  PercentUnique  = round(UniqueValues / nrow(data) * 100, 2),
  MissingValues  = map_int(data, ~ sum(is.na(.x))),
  PercentMissing = round(MissingValues / nrow(data) * 100, 2),
  ZeroValues     = map_int(data, ~ if (is.numeric(.x)) sum(.x == 0, na.rm = TRUE) else NA_integer_),
  PercentZero    = round(ZeroValues / nrow(data) * 100, 2),
  TopValues      = map_chr(data, get_top_values)
)

datatable(
  overview_df,
  rownames = FALSE,
  options = list(
    dom = "t",
    pageLength = 27,
    scrollX = TRUE
  )
)
datatable(
  data,
  rownames = FALSE,
  options = list(
    pageLength = 10,
    scrollX = TRUE
  )
)

3 Univariate analysis – categorical variables

3.1 Respondent Identifiers and Demographics

3.1.1 Student Name

student_name_tbl <- freq_table(data, StudentName)
datatable(student_name_tbl, rownames = FALSE, options = list(dom = "tp", pageLength = 10))

3.1.2 IU Student Status

iu_student_tbl <- freq_table(data, IUStudent)
datatable(iu_student_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(iu_student_tbl, type = "column", hcaes(x = IUStudent, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.2 Visit Behavior and Purpose

3.2.1 VisitTime

visit_time_tbl <- freq_table(data, VisitTime)
datatable(visit_time_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(visit_time_tbl, type = "bar", hcaes(x = VisitTime, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.2.2 Visit Purpose

visit_purpose_tbl <- freq_table(data, VisitPurpose)
datatable(visit_purpose_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(visit_purpose_tbl, type = "bar", hcaes(x = VisitPurpose, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.2.3 Stay Reason

stay_reason_tbl <- freq_table(data, StayReason)
datatable(stay_reason_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(stay_reason_tbl, type = "bar", hcaes(x = StayReason, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.2.4 Overcrowd Alternative

alternative_tbl <- freq_table(data, OvercrowdAlternative)
datatable(alternative_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(alternative_tbl, type = "bar", hcaes(x = OvercrowdAlternative, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3 Capacity, Waiting Times, and Seating Conditions

3.3.1 Fullness Level

fullness_tbl <- freq_table(data, FullnessLevel, sort_desc = FALSE)
datatable(fullness_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(fullness_tbl, type = "bar", hcaes(x = FullnessLevel, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.2 Queue Time

queue_time_tbl <- freq_table(data, QueueTime, sort_desc = FALSE)
datatable(queue_time_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(queue_time_tbl, type = "column", hcaes(x = QueueTime, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.3 Food Wait Time

food_wait_tbl <- freq_table(data, FoodWaitTime, sort_desc = FALSE)
datatable(food_wait_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(food_wait_tbl, type = "column", hcaes(x = FoodWaitTime, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.4 Seat Find Time

seat_find_tbl <- freq_table(data, SeatFindTime)
datatable(seat_find_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(seat_find_tbl, type = "bar", hcaes(x = SeatFindTime, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.5 Table Finding Difficulty

table_diff_tbl <- freq_table(data, TableDifficulty, sort_desc = FALSE)
datatable(table_diff_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(table_diff_tbl, type = "bar", hcaes(x = TableDifficulty, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.6 Table Cleanliness

cleanliness_tbl <- freq_table(data, TableCleanliness)
datatable(cleanliness_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(cleanliness_tbl, type = "bar", hcaes(x = TableCleanliness, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.7 Sold Out Freq

soldout_tbl <- freq_table(data, SoldOutFreq, sort_desc = FALSE)
datatable(soldout_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(soldout_tbl, type = "column", hcaes(x = SoldOutFreq, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.3.8 Max Wait Tolerated

max_wait_tbl <- freq_table(data, MaxWaitTolerated, sort_desc = FALSE)
datatable(max_wait_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(max_wait_tbl, type = "column", hcaes(x = MaxWaitTolerated, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.4 Operational Perceptions and Policies

3.4.1 Notice External Students

external_tbl <- freq_table(data, NoticeExternalStudents, sort_desc = FALSE)
datatable(external_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(external_tbl, type = "column", hcaes(x = NoticeExternalStudents, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.4.2 Rule Clarity

rule_clarity_tbl <- freq_table(data, RuleClarity, sort_desc = FALSE)
datatable(rule_clarity_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(rule_clarity_tbl, type = "column", hcaes(x = RuleClarity, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.4.3 Priority Improvement

priority_tbl <- freq_table(data, PriorityImprovement)
datatable(priority_tbl, rownames = FALSE, options = list(dom = "t"))
hchart(priority_tbl, type = "bar", hcaes(x = PriorityImprovement, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.5 Multi-Select and Open-Ended Responses

3.5.1 Bottleneck Stage

bottleneck_tbl <- freq_table(data, BottleneckStage)
datatable(bottleneck_tbl, rownames = FALSE, options = list(dom = "tp", pageLength = 10))
hchart(bottleneck_tbl, type = "bar", hcaes(x = BottleneckStage, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.5.2 Overcrowd Causes

causes_tbl <- freq_table(data, OvercrowdCauses)
datatable(causes_tbl, rownames = FALSE, options = list(dom = "tp", pageLength = 10))
hchart(causes_tbl, type = "bar", hcaes(x = OvercrowdCauses, y = NumberOfResponses), name = "Responses") %>%
  hc_chart(zoomType = "xy")

3.5.3 Feedback Suggestions

feedback_tbl <- freq_table(data, FeedbackSuggestions)
datatable(feedback_tbl, rownames = FALSE, options = list(dom = "tp", pageLength = 10))

4 Univariate analysis – numerical variables

4.1 Summary statistics

# Select all 6 numerical satisfaction variables
num_vars <- c(
  "SatQueueing", "SatFoodPickup", "SatSeating",
  "SatCleanliness", "SatTotalTime", "SatOverall"
)

# Helper function to compute statistical Mode
get_mode <- function(x) {
  x_clean <- na.omit(x)
  ux <- unique(x_clean)
  ux[which.max(tabulate(match(x_clean, ux)))]
}

# Build comprehensive summary statistics table
summary_num_df <- map_dfr(num_vars, function(var_name) {
  x <- data[[var_name]]
  q1_val <- as.numeric(quantile(x, 0.25, na.rm = TRUE))
  q3_val <- as.numeric(quantile(x, 0.75, na.rm = TRUE))
  min_val <- min(x, na.rm = TRUE)
  max_val <- max(x, na.rm = TRUE)
  
  tibble(
    Variable = var_name,
    Mean     = round(mean(x, na.rm = TRUE), 2),
    Median   = round(median(x, na.rm = TRUE), 2),
    Mode     = get_mode(x),
    Min      = min_val,
    Q1       = round(q1_val, 2),
    Q3       = round(q3_val, 2),
    Max      = max_val,
    Range    = max_val - min_val,
    IQR      = round(q3_val - q1_val, 2),
    Variance = round(var(x, na.rm = TRUE), 2)
  )
})

datatable(
  summary_num_df,
  rownames = FALSE,
  options = list(dom = "t", scrollX = TRUE)
)

4.2 Distributions

4.2.1 SatQueueing

sat_queue_dist <- data %>%
  count(SatQueueing, name = "NumberOfResponses") %>%
  arrange(SatQueueing)

datatable(sat_queue_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_queue_dist, type = "column", hcaes(x = SatQueueing, y = NumberOfResponses), name = "SatQueueing") %>%
  hc_chart(zoomType = "xy")

4.2.2 SatFoodPickup

sat_food_dist <- data %>%
  count(SatFoodPickup, name = "NumberOfResponses") %>%
  arrange(SatFoodPickup)

datatable(sat_food_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_food_dist, type = "column", hcaes(x = SatFoodPickup, y = NumberOfResponses), name = "SatFoodPickup") %>%
  hc_chart(zoomType = "xy")

4.2.3 SatSeating

sat_seat_dist <- data %>%
  count(SatSeating, name = "NumberOfResponses") %>%
  arrange(SatSeating)

datatable(sat_seat_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_seat_dist, type = "column", hcaes(x = SatSeating, y = NumberOfResponses), name = "SatSeating") %>%
  hc_chart(zoomType = "xy")

4.2.4 SatCleanliness

sat_clean_dist <- data %>%
  count(SatCleanliness, name = "NumberOfResponses") %>%
  arrange(SatCleanliness)

datatable(sat_clean_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_clean_dist, type = "column", hcaes(x = SatCleanliness, y = NumberOfResponses), name = "SatCleanliness") %>%
  hc_chart(zoomType = "xy")

4.2.5 SatTotalTime

sat_time_dist <- data %>%
  count(SatTotalTime, name = "NumberOfResponses") %>%
  arrange(SatTotalTime)

datatable(sat_time_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_time_dist, type = "column", hcaes(x = SatTotalTime, y = NumberOfResponses), name = "SatTotalTime") %>%
  hc_chart(zoomType = "xy")

4.2.6 SatOverall

sat_overall_dist <- data %>%
  count(SatOverall, name = "NumberOfResponses") %>%
  arrange(SatOverall)

datatable(sat_overall_dist, rownames = FALSE, options = list(dom = "t"))
hchart(sat_overall_dist, type = "column", hcaes(x = SatOverall, y = NumberOfResponses), name = "SatOverall") %>%
  hc_chart(zoomType = "xy")

4.3 Outliers

# Compute IQR outlier limits and counts for each numerical variable
outliers_df <- map_dfr(num_vars, function(var_name) {
  x <- na.omit(data[[var_name]])
  q1 <- as.numeric(quantile(x, 0.25))
  q3 <- as.numeric(quantile(x, 0.75))
  iqr_val <- q3 - q1
  lower <- q1 - 1.5 * iqr_val
  upper <- q3 + 1.5 * iqr_val
  
  tibble(
    Variable   = var_name,
    LowerLimit = round(lower, 2),
    UpperLimit = round(upper, 2),
    BelowLower = sum(x < lower),
    AboveUpper = sum(x > upper)
  )
})

datatable(
  outliers_df,
  rownames = FALSE,
  options = list(dom = "t")
)
# Reshape numerical variables to long format for side-by-side interactive boxplot
sat_long <- data %>%
  select(all_of(num_vars)) %>%
  pivot_longer(cols = everything(), names_to = "Variable", values_to = "Score") %>%
  filter(!is.na(Score))

hcboxplot(
  x = sat_long$Score,
  var = sat_long$Variable,
  outliers = TRUE
) %>%
  hc_chart(type = "column", zoomType = "xy") %>%
  hc_yAxis(title = list(text = "Satisfaction Score"))

5 Bivariate analysis

5.1 VisitTime × FullnessLevel

time_fullness_tbl <- data %>%
  filter(!is.na(VisitTime), !is.na(FullnessLevel)) %>%
  count(VisitTime, FullnessLevel, name = "Responses") %>%
  group_by(VisitTime) %>%
  mutate(RowPercent = round(Responses / sum(Responses) * 100, 2)) %>%
  ungroup()

datatable(
  time_fullness_tbl,
  rownames = FALSE,
  options = list(dom = "tp", pageLength = 10, scrollX = TRUE)
)
hchart(
  time_fullness_tbl,
  type = "column",
  hcaes(x = VisitTime, y = RowPercent, group = FullnessLevel)
) %>%
  hc_plotOptions(column = list(stacking = "percent")) %>%
  hc_yAxis(title = list(text = "Percentage of Responses (%)")) %>%
  hc_xAxis(title = list(text = "Visit Time Window")) %>%
  hc_chart(zoomType = "xy")

5.2 QueueTime × SatQueueing

queue_sat_summary <- data %>%
  filter(!is.na(QueueTime), !is.na(SatQueueing)) %>%
  group_by(QueueTime) %>%
  summarise(
    Responses   = n(),
    SatMean     = round(mean(SatQueueing), 2),
    SatMedian   = median(SatQueueing),
    SatQ1       = as.numeric(quantile(SatQueueing, 0.25)),
    SatQ3       = as.numeric(quantile(SatQueueing, 0.75)),
    SatMin      = min(SatQueueing),
    SatMax      = max(SatQueueing),
    .groups     = "drop"
  )

datatable(
  queue_sat_summary,
  rownames = FALSE,
  options = list(dom = "t", scrollX = TRUE)
)
queue_sat_clean <- data %>%
  filter(!is.na(QueueTime), !is.na(SatQueueing))

hcboxplot(
  x = queue_sat_clean$SatQueueing,
  var = queue_sat_clean$QueueTime,
  outliers = TRUE
) %>%
  hc_chart(type = "column", zoomType = "xy") %>%
  hc_xAxis(title = list(text = "Queueing Time Bracket")) %>%
  hc_yAxis(title = list(text = "Queueing Satisfaction Score (1–5)"))

5.3 IUStudent × OvercrowdAlternative

iu_alt_tbl <- data %>%
  filter(!is.na(IUStudent), !is.na(OvercrowdAlternative)) %>%
  count(IUStudent, OvercrowdAlternative, name = "Responses") %>%
  group_by(IUStudent) %>%
  mutate(GroupPercent = round(Responses / sum(Responses) * 100, 2)) %>%
  ungroup()

datatable(
  iu_alt_tbl,
  rownames = FALSE,
  options = list(dom = "t", scrollX = TRUE)
)
hchart(
  iu_alt_tbl,
  type = "bar",
  hcaes(x = OvercrowdAlternative, y = GroupPercent, group = IUStudent)
) %>%
  hc_yAxis(title = list(text = "Percentage Within Group (%)")) %>%
  hc_xAxis(title = list(text = "Alternative Action During Overcrowding")) %>%
  hc_chart(zoomType = "xy")

5.4 SatTotalTime × SatOverall

time_overall_summary <- data %>%
  filter(!is.na(SatTotalTime), !is.na(SatOverall)) %>%
  group_by(SatTotalTime) %>%
  summarise(
    Responses      = n(),
    OverallMedian  = median(SatOverall),
    OverallQ1      = as.numeric(quantile(SatOverall, 0.25)),
    OverallQ3      = as.numeric(quantile(SatOverall, 0.75)),
    OverallMin     = min(SatOverall),
    OverallMax     = max(SatOverall),
    .groups        = "drop"
  )

datatable(
  time_overall_summary,
  rownames = FALSE,
  options = list(dom = "t")
)
time_overall_clean <- data %>%
  filter(!is.na(SatTotalTime), !is.na(SatOverall)) %>%
  mutate(SatTotalTime = factor(SatTotalTime, levels = 1:5))

hcboxplot(
  x = time_overall_clean$SatOverall,
  var = time_overall_clean$SatTotalTime,
  outliers = TRUE
) %>%
  hc_chart(type = "column", zoomType = "xy") %>%
  hc_xAxis(title = list(text = "Satisfaction with Total Time Spent (1–5)")) %>%
  hc_yAxis(title = list(text = "Overall Canteen Satisfaction (1–5)"))