Volleyball Hub

Welcome Header

๐Ÿ Volleyball Analytics Dashboard

Analyzing VNL 2025 Grand Finals, PlusLiga 2008-2023, and VNL Beach 2025

Interactive Dashboard โ€ข December 2025

League Quick Facts

Row

PlusLiga 2024/25 ๐Ÿ‡ต๐Ÿ‡ฑ

8 Months

Oct - May

16 Teams

Professional Clubs

โ‚ฌ1.5M+

Total Prize Pool

VNL Indoor Facts ๐Ÿ

6 Weeks

June - July

24 Teams

18 Nations

16+ Nations

Participating Countries

$4M+

Total Prize Pool

Beach Pro Tour Facts ๐Ÿ–๏ธ

14+ Stops

Global Locations

6 Continents

Worldwide Reach

Elite 16

Top Tier Events

Row

๐ŸŒ Geographic Scope

The Leagues:

  • PlusLiga: National league (Poland only)
  • VNL: There are 18 nations who compete in the FIVB VNL. These countries are multi-continental with teams such as China, Cuba, Bulgaria, Turkey, and many more.
  • Beach Tour: Global circuit (40+ countries)

Geographic Reach

Year-Round

Overview

Row

Why This Matters

๐Ÿ Why Study Volleyball Analytics?

Volleyball represents one of the fastest-growing professional sports globally, yet its statistical analysis lags behind sports like basketball and soccer. These visualizations aim to bridge that gap by:

  • ๐Ÿ“ˆ Identifying key performance indicators that predict team success
  • ๐Ÿ”„ Analyzing how age correlates to success
  • ๐Ÿ Comparing where the ball travels over the course of the game
  • ๐Ÿ”ฎ Examining Common Trends

As a data enthusiast and volleyball fan, I believe data-driven insights can enhance both team performance and fan engagement in the sport.

Row

๐ŸŽฏ Personal Motivation

My interest in volleyball analytics stems from:

  • Playing intramural volleyball for 2 years
  • Observing how data transformed other professional sports
  • Noticing limited statistical resources available to volleyball enthusiasts
  • Wanting to dip my feet into sports analytics

๐ŸŽฏ Key Questions

This dashboard seeks to answer:

  • Is there a difference in duration between genders?
  • Does age affect winning probability?
  • What separates elite beach volleyball pairs from average ones?
  • How impactful is the middle of the court?

VNL 2025 Finals

Data Analysis Sections

Row

VNL 2025 Grand Finals

๐Ÿ† VNL 2025 Grand Finals

This analysis used the Italy vs Poland VNL 2025 match video, tracking ball movement throughout the game to identify spatial patterns and tactical tendencies using computer vision and the OpenVolley package.


Volleyball is an intense sport where the ball travels all over the court but there has to be a pattern to maintain the flow without it being pure chaos. This is clearly illustrated by both the heatmap and the histogram. Starting with the histogram, the middle of the court is clearly the most intense place and there are a lot of reasons for this. Service takes place from the center back and so while they wait for the whistle they hold the ball. Additionally, the setter operates as a central hub at the net. Their positioning maximizes offensive options and includes the threat of a dump which further concentrates events in this region. Furthermore, a high volume of passes, sets, and quick attacks are funneled through this central corridor. Consequently, with setters, the Middle Blocker can be used as a decoy or the greatest weapon. The middle is a battle of height and who can reach the peak of their jump first or who can get the highest. Either way, it is an intense place which draws attention. For example, a successful middle-blocker decoy often creates isolated blocking opportunities for the outside hitters attacking from the pins. All of these factors contribute to why the middle of the court sees so much play. The heatmap, conversely, shows clear density spikes at the court's edges and the attack line. This makes it very clear where setters will send the ball. These spikes correspond directly to the primary attack zones of specific position players. Typically the edges belong to the Outside or Opposite Hitters. These two are responsible for fighting at the pins and will either hit crosses to go across the court and negate the blocks or try and hit a line shot to get on the edge of the court. The density clusters just behind the attack line are often the result of strategic back-row attacks. When a primary hitter rotates to the back row, setters frequently utilize them to keep the offense multi-dimensional and pressure the defense. This pattern indicates a deliberate tactical preference to leverage powerful back-row attackers, like the opposite hitter, as a consistent offensive option from deep positions. Secondary density marks throughout the court typically indicate successful tactical shots, such as sharp-angle attacks or tips into defensive gaps created by the opponent's formation. In professional volleyball the gaps close quickly due to blockers and typically due to the formation of such blocks the cross shot typically lands in the center.


All in all, this heatmap provided fascinating insight and it was a very interesting process to make work.

Data Source Information

Row

About the Data

๐Ÿ“‹ Data Sources


Research Question:

Where is the ball typically located on the court over the course of a game?


Dashboard created with R flexdashboard โ€ข Updated: December 2025

VNL Beach 2025

Data Analysis Sections

Row

VNL Beach 2025

๐Ÿ–๏ธ VNL Beach 2025

An analysis of match duration by gender reveals distinct patterns in game flow and variability. First, we notice that the mode length of a match is around 40 minutes. However, the distribution of men's match times shows a wider spread in its central portion. There seems to be greater variability as many games continue past 60 minutes but there are several short games too. In contrast, the women's data exhibits a tighter concentration around the mode, suggesting more consistent match durations and a more predictable game flow. The right tail for women's games is also significantly smaller and suggests male games can be drawn out more.


When exploring the ages of players there is a pronounced peak within the 27-30 year range. The distribution closely approximates a bell curve, reflecting the natural attrition of athletes at both ends of the age spectrum. The comparative analysis of winners' and losers' ages reveals no significant systemic age disadvantage. In fact one could argue that as you get older your odds to win go up, explained by the accumulation of strategic experience and technical mastery.

Data Source Information

Row

About the Data

๐Ÿ“‹ Data Sources


Research Question:

How do non-controllable factors (Gender and Age) affect match outcomes?


Dashboard created with R flexdashboard โ€ข Updated: December 2025

PlusLiga 2008-2023

Data Analysis Sections

Row

PlusLiga 2008-2023

๐Ÿ‡ต๐Ÿ‡ฑ PlusLiga

While the data is drawn solely from Poland's PlusLiga, the league's consistent production of elite, internationally competitive players makes its data a valuable proxy for high-level volleyball trends. Surprisingly, there seems to be no significant difference in serve effectiveness between the two teams at any given time. This implies not only a remarkable consistency in serving performance among elite players but also that match outcomes are not dictated by serving alone.


Furthermore, a strong positive correlation between offensive and defensive efficiency metrics highlights the sport's integrated nature. If a team has poor receives then the setter cannot get a good ball to the hitters, which puts their offense at a severe disadvantage. Conversely, failing to terminate a high-quality attack opportunity wastes defensive effort.


Finally, blocking frequency establishes a realistic expectation for match tempo and momentum shifts. In elite volleyball, blocking is not merely passive defense but a high-risk, high-reward offensive weapon.

Data Source Information

Row

About the Data

๐Ÿ“‹ Data Sources


Research Question:

What is the distribution and impact of key match statistics?


Dashboard created with R flexdashboard โ€ข Updated: December 2025

---
title: "Kohn Dashboard Capstone Project - Volleyball Analytics"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
    theme: flatly
    source_code: embed
    navbar:
      - { title: "GitHub Repo", icon: "fa-github", href: "https://github.com/rkohnmn/MTH229", align: right }
---

```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
library(plotly)
library(ggplot2)
library(dplyr)
library(fontawesome)
library(shiny)
library(stringr)
library(tidyverse)
library(tidyr)
library(MASS)
library(mosaic)
library(lubridate)
library(readr)
library(viridis)

set.seed(67)

# Helper function to find existing data files (local sample or original full dataset)
find_data_file <- function(primary_local, backup_sample, backup_original) {
  if (file.exists(primary_local)) {
    return(primary_local)
  } else if (file.exists(backup_original)) {
    return(backup_original)
  } else if (file.exists(backup_sample)) {
    return(backup_sample)
  }
  return(primary_local)
}
```

# **Volleyball Hub**

### Welcome Header {.no-title}
```{r welcome-header, echo=FALSE}
tags$div(
  style = "background: linear-gradient(135deg, #1e3c72, #2a5298); 
           padding: 20px; border-radius: 10px; color: white; text-align: center;",
  h1("๐Ÿ Volleyball Analytics Dashboard", style = "margin-bottom: 10px;"),
  h4("Analyzing VNL 2025 Grand Finals, PlusLiga 2008-2023, and VNL Beach 2025", 
     style = "opacity: 0.9;"),
  tags$p("Interactive Dashboard โ€ข December 2025", style = "font-style: italic;")
)
```

## **League Quick Facts**

Row {data-height=220}
-----------------------------------------------------------------------

### **PlusLiga 2024/25 ๐Ÿ‡ต๐Ÿ‡ฑ**

```{r quick-stats-pl}
tags$div(
  style = "display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 15px;",
  
  # Season Length
  tags$div(
    style = "background: linear-gradient(135deg, #1e3c72, #2980b9); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("8 Months", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("calendar"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("Oct - May", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Total Teams
  tags$div(
    style = "background: linear-gradient(135deg, #2980b9, #3498db); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("16 Teams", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("users"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("Professional Clubs", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Prize Pool
  tags$div(
    style = "background: linear-gradient(135deg, #3498db, #85c1e9); 
             padding: 15px; border-radius: 8px; color: #2c3e50; text-align: center;
             border: 2px solid #1e3c72;",
    tags$h3("โ‚ฌ1.5M+", style = "margin: 0; font-size: 24px; color: #1e3c72;"),
    tags$p(icon("trophy"), style = "font-size: 20px; margin: 5px 0; color: #f39c12;"),
    tags$p("Total Prize Pool", style = "margin: 0; font-size: 12px; opacity: 0.8;")
  )
)
```

### **VNL Indoor Facts ๐Ÿ**

```{r quick-stats-vnl}
tags$div(
  style = "display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 15px;",
  
  # Tournament Duration
  tags$div(
    style = "background: linear-gradient(135deg, #27ae60, #2ecc71); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("6 Weeks", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("clock"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("June - July", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Total Teams
  tags$div(
    style = "background: linear-gradient(135deg, #2ecc71, #58d68d); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("24 Teams", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("users"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("18 Nations", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Global Reach
  tags$div(
    style = "background: linear-gradient(135deg, #58d68d, #abebc6); 
             padding: 15px; border-radius: 8px; color: #2c3e50; text-align: center;",
    tags$h3("16+ Nations", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("globe"), style = "font-size: 20px; margin: 5px 0; color: #27ae60;"),
    tags$p("Participating Countries", style = "margin: 0; font-size: 12px; opacity: 0.8;")
  ),
  
  # Prize Pool
  tags$div(
    style = "background: linear-gradient(135deg, #abebc6, #e8f8f5); 
             padding: 15px; border-radius: 8px; color: #2c3e50; text-align: center; 
             border: 2px solid #27ae60;",
    tags$h3("$4M+", style = "margin: 0; font-size: 24px; color: #27ae60;"),
    tags$p(icon("trophy"), style = "font-size: 20px; margin: 5px 0; color: #e67e22;"),
    tags$p("Total Prize Pool", style = "margin: 0; font-size: 12px; opacity: 0.8;")
  )
)
```

### **Beach Pro Tour Facts ๐Ÿ–๏ธ**

```{r quick-stats-bpt}
tags$div(
  style = "display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 15px;",
  
  # Global Stops
  tags$div(
    style = "background: linear-gradient(135deg, #e67e22, #f39c12); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("14+ Stops", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("map-marker-alt"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("Global Locations", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Continents
  tags$div(
    style = "background: linear-gradient(135deg, #f39c12, #f8c471); 
             padding: 15px; border-radius: 8px; color: white; text-align: center;",
    tags$h3("6 Continents", style = "margin: 0; font-size: 24px;"),
    tags$p(icon("globe-americas"), style = "font-size: 20px; margin: 5px 0;"),
    tags$p("Worldwide Reach", style = "margin: 0; font-size: 12px; opacity: 0.9;")
  ),
  
  # Elite Events
  tags$div(
    style = "background: linear-gradient(135deg, #f8c471, #fdebd0); 
             padding: 15px; border-radius: 8px; color: #2c3e50; text-align: center;
             border: 2px solid #e67e22;",
    tags$h3("Elite 16", style = "margin: 0; font-size: 24px; color: #e67e22;"),
    tags$p(icon("crown"), style = "font-size: 20px; margin: 5px 0; color: #f1c40f;"),
    tags$p("Top Tier Events", style = "margin: 0; font-size: 12px; opacity: 0.8;")
  )
)
```

Row {data-height=200}
-----------------------------------------------------------------------

### **๐ŸŒ Geographic Scope**
```{r}
tags$div(
  style = "padding: 20px; background-color: #e8f4f8; border-radius: 8px;",
  h4("The Leagues:"),
  tags$ul(
    tags$li(tags$strong("PlusLiga:"), " National league (Poland only)"),
    tags$li(tags$strong("VNL:"), " There are 18 nations who compete in the FIVB VNL. These countries are multi-continental with teams such as China, Cuba, Bulgaria, Turkey, and many more."),
    tags$li(tags$strong("Beach Tour:"), " Global circuit (40+ countries)")
  )
)
```

### **Geographic Reach**
```{r}
valueBox("Year-Round", "Continuous Competition", 
         icon = fa_i("calendar-alt"), 
         color = "info")
```

# **Overview** {#overview}

Row {data-height=450}
-----------------------------------------------------------------------

### **Why This Matters**
```{r purpose}
tags$div(
  style = "padding: 20px; background: linear-gradient(135deg, #f8f9fa, #e9ecef); 
           border-radius: 10px;",
  h3("๐Ÿ Why Study Volleyball Analytics?"),
  p("Volleyball represents one of the fastest-growing professional sports globally, yet its statistical analysis lags behind sports like basketball and soccer. These visualizations aim to bridge that gap by:"),
  tags$ul(
    tags$li("๐Ÿ“ˆ Identifying key performance indicators that predict team success"),
    tags$li("๐Ÿ”„ Analyzing how age correlates to success"),
    tags$li("๐Ÿ Comparing where the ball travels over the course of the game"),
    tags$li("๐Ÿ”ฎ Examining Common Trends")
  ),
  br(),
  p("As a data enthusiast and volleyball fan, I believe data-driven insights can enhance both team performance and fan engagement in the sport.")
)
```

Row {data-height=200}
-----------------------------------------------------------------------

```{r motivation}
tags$div(
  style = "padding: 20px; background-color: #e8f4f8; border-radius: 10px;",
  h4("๐ŸŽฏ Personal Motivation"),
  p("My interest in volleyball analytics stems from:"),
  tags$ul(
    tags$li("Playing intramural volleyball for 2 years"),
    tags$li("Observing how data transformed other professional sports"),
    tags$li("Noticing limited statistical resources available to volleyball enthusiasts"),
    tags$li("Wanting to dip my feet into sports analytics")
  )
)
```

```{r questions}
tags$div(
  style = "padding: 20px; background-color: #f3e8ff; border-radius: 10px;",
  h4("๐ŸŽฏ Key Questions"),
  p("This dashboard seeks to answer:"),
  tags$ul(
    tags$li("Is there a difference in duration between genders?"),
    tags$li("Does age affect winning probability?"),
    tags$li("What separates elite beach volleyball pairs from average ones?"),
    tags$li("How impactful is the middle of the court?")
  )
)
```

# **VNL 2025 Finals** {#VNL}

## **Data Analysis Sections**

Row {data-height=450}
-----------------------------------------------------------------------

### VNL 2025 Grand Finals {data-icon="fa-trophy"}

```{r vnl-section}
ball_file <- find_data_file(
  primary_local = "data/ball_positions.csv",
  backup_sample = "data/ball_positions_sample.csv",
  backup_original = "../../Volleyball Tackin/ball_positions.csv"
)

ball_data <- read_csv(ball_file, show_col_types = FALSE)
ball_data$x_court <- -9 + ball_data$u * 18  # u in [0,1] mapped to [-9,9]
y_min_clip <- 2.9
y_max_clip <- 9
ball_data$y_court <- pmax(pmin(ball_data$v * 9, y_max_clip), y_min_clip)
ball_data$y_court <- (ball_data$y_court - y_min_clip) / (y_max_clip - y_min_clip) * 9

z <- kde2d(
  x = ball_data$x_court,
  y = ball_data$y_court,
  n = 200,
  lims = c(-9, 9, 0, 9)
)
z$z <- sqrt(sqrt(z$z))

par(mar = c(4, 3.5, 4, 8))
plot.new()
plot.window(xlim = c(-10, 12.5), ylim = c(-1, 10), xaxs = "i", yaxs = "i")
rect(-10, -1, 12.5, 10, col = "gray95", border = NA)

image(
  z,
  col = viridis(30, option = "plasma", alpha = 0.55),
  xlim = c(-9, 9),
  ylim = c(0, 9),
  axes = FALSE,
  xlab = "",
  ylab = "",
  add = TRUE
)

title(main = "Volleyball Ball Position Heatmap", 
      line = 2.5, cex.main = 1.4, font.main = 2, col.main = "gray20")
mtext("Court Position Density During Play", 
      line = 1, cex = 1, col = "gray40")

rect(-9, 0, 9, 9, border = "gray30", lwd = 2.5)
abline(v = 0, lwd = 2.5, col = "gray30")
abline(v = -3, lty = "dashed", lwd = 1.5, col = "gray50")
abline(v = 3, lty = "dashed", lwd = 1.5, col = "gray50")

rect(-9, 0, 0, 9, border = NA, col = rgb(0.2, 0.4, 0.8, 0.08))
rect(0, 0, 9, 9, border = NA, col = rgb(0.8, 0.2, 0.2, 0.08))
rect(-9, 0, -3, 9, border = NA, col = rgb(0.2, 0.4, 0.8, 0.12))
rect(-3, 0, 0, 9, border = NA, col = rgb(0.2, 0.4, 0.8, 0.05))
rect(3, 0, 9, 9, border = NA, col = rgb(0.8, 0.2, 0.2, 0.12))
rect(0, 0, 3, 9, border = NA, col = rgb(0.8, 0.2, 0.2, 0.05))

mtext("Court Length (meters)", side = 1, line = 2.2, cex = 1.1, col = "gray30")
mtext("Court Width (meters)", side = 2, line = 2.2, cex = 1.1, col = "gray30")

abline(h = seq(0, 9, by = 3), lty = "dotted", col = "gray80", lwd = 0.7)
abline(v = seq(-9, 9, by = 3), lty = "dotted", col = "gray80", lwd = 0.7)

text(-4.5, 8.5, "POLAND", cex = 1.1, font = 2, col = "navyblue")
text(4.5, 8.5, "ITALY", cex = 1.1, font = 2, col = "firebrick")

text(-6, 3.5, "Defense Zone", cex = 0.8, col = "#50C878", srt = 90)
text(-1.5, 3.5, "Attack Zone", cex = 0.8, col = "#50C878", srt = 90)
text(1.5, 3.5, "Attack Zone", cex = 0.8, col = "#50C878", srt = 90)
text(6, 3.5, "Defense Zone", cex = 0.8, col = "#50C878", srt = 90)

cols <- viridis(30, option = "plasma", alpha = 0.85)
legend_x <- 9.1  
legend_y <- seq(0, 9, length.out = length(cols) + 1)

rect(legend_x - 0.1, -0.2, legend_x + 1.3, 9.2, col = "white", border = "gray70", lwd = 0.8)

for(i in 1:length(cols)){
  rect(legend_x, legend_y[i], legend_x + 0.5, legend_y[i+1], 
       col = cols[i], border = NA)
}

text(legend_x + 0.25, 9.3, "Ball Density", adj = 0.5, cex = 1, font = 2, col = "gray30")

text(legend_x + 0.6, seq(0, 9, length.out = 5), 
     labels = sprintf("%.2f", seq(min(z$z), max(z$z), length.out = 5)), 
     adj = 0, cex = 0.85, col = "gray40")

segments(-0.1, 0, -0.1, 9, lwd = 3, col = "gray50")
segments(0.1, 0, 0.1, 9, lwd = 3, col = "gray50")
text(0, -0.7, "NET", cex = 0.9, font = 2, col = "gray40")  

hist(ball_data$y_court, breaks = 20, main = "Distribution of Ball Positions Along Court Y-Axis", xlab = "Court Y Position", ylab = "Frequency", col = "steelblue", border = "white", cex.main = 1.3, cex.lab = 1.1, cex.axis = 1, font.main = 2, las = 1, tcl = -0.3, mgp = c(2.5, 0.7, 0), bty = "n")

tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ† VNL 2025 Grand Finals"),
  p("This analysis used the Italy vs Poland VNL 2025 match video, tracking ball",
    " movement throughout the game to identify spatial patterns and tactical",
    " tendencies using computer vision and the OpenVolley package."),
  br(),
  p("Volleyball is an intense sport where the ball travels all over the court but there has to be a pattern to maintain the flow without it being pure chaos. This is clearly illustrated by both the heatmap and the histogram. Starting with the histogram, the middle of the court is clearly the most intense place and there are a lot of reasons for this. Service takes place from the center back and so while they wait for the whistle they hold the ball. Additionally, the setter operates as a central hub at the net. Their positioning maximizes offensive options and includes the threat of a dump which further concentrates events in this region. Furthermore, a high volume of passes, sets, and quick attacks are funneled through this central corridor. Consequently, with setters, the Middle Blocker can be used as a decoy or the greatest weapon. The middle is a battle of height and who can reach the peak of their jump first or who can get the highest. Either way, it is an intense place which draws attention. For example, a successful middle-blocker decoy often creates isolated blocking opportunities for the outside hitters attacking from the pins. All of these factors contribute to why the middle of the court sees so much play. The heatmap, conversely, shows clear density spikes at the court's edges and the attack line. This makes it very clear where setters will send the ball. These spikes correspond directly to the primary attack zones of specific position players. Typically the edges belong to the Outside or Opposite Hitters. These two are responsible for fighting at the pins and will either hit crosses to go across the court and negate the blocks or try and hit a line shot to get on the edge of the court. The density clusters just behind the attack line are often the result of strategic back-row attacks. When a primary hitter rotates to the back row, setters frequently utilize them to keep the offense multi-dimensional and pressure the defense. This pattern indicates a deliberate tactical preference to leverage powerful back-row attackers, like the opposite hitter, as a consistent offensive option from deep positions. Secondary density marks throughout the court typically indicate successful tactical shots, such as sharp-angle attacks or tips into defensive gaps created by the opponent's formation. In professional volleyball the gaps close quickly due to blockers and typically due to the formation of such blocks the cross shot typically lands in the center."),
  br(),
  p("All in all, this heatmap provided fascinating insight and it was a very interesting process to make work.")
)
```

## **Data Source Information**

Row {data-height=300}
-----------------------------------------------------------------------

### About the Data {#datasource}

```{r data-source}
tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ“‹ Data Sources"),
  tags$ul(
    tags$li(tags$strong("VNL 2025 Grand Finals:"), 
            " Ball tracking analysis from Italy vs Poland match using ",
            tags$a(href="https://www.youtube.com/watch?v=VL4WutaWt9U", 
                   "YouTube Game Recording", target="_blank"),
            " processed with ",
            tags$a(href="https://openvolley.org/", 
                   "OpenVolley/ovml R package", target="_blank"))
  ),
  hr(),
  h4("Research Question:"),
  p("Where is the ball typically located on the court over the course of a game?"),
  hr(),
  p("Dashboard created with R flexdashboard โ€ข Updated: December 2025")
)
```

# **VNL Beach 2025** {#beach}

## **Data Analysis Sections**

Row {data-height=450}
-----------------------------------------------------------------------

### VNL Beach 2025 {data-icon="fa-umbrella-beach"}

```{r beach-section}
beach_file <- find_data_file(
  primary_local = "data/vb_matches.csv",
  backup_sample = "data/vb_matches_sample.csv",
  backup_original = "../../vb_matches.csv"
)

vb_data  <- read_csv(beach_file, show_col_types = FALSE)
vb_clean <- vb_data %>% 
  mutate(duration_min = as.numeric(hms(duration)) / 60,
         w_p1_age = as.numeric(w_p1_age), 
         l_p1_age = as.numeric(l_p1_age))

# Graph 1: Match duration by gender 
gf_histogram(~ duration_min, fill = ~ gender, data = vb_clean, bins = 20, alpha = 0.6) %>% 
  gf_facet_wrap(~ gender, nrow = 2) %>%
  gf_labs(title = "Male Beach Matches Tend to be Longer", 
          subtitle = "Comparison of match length patterns between male and female players", 
          x = "Duration (minutes)", y = "Count", fill = "Gender", 
          caption = "Data source: Kaggle: jessemostipak") %>%
  gf_theme(legend.position = "none", 
           plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
           plot.subtitle = element_text(size = 11, color = "gray40", hjust = 0.5))

# Graph 2: Age distribution
age_data <- data.frame(age = c(vb_clean$w_p1_age, vb_clean$l_p1_age))
gf_histogram(~ age, data = age_data, bins = 20, fill="darkred") %>%
  gf_labs(title="Most players are around 30 years old",
          subtitle = "Age Distribution of Players",
          x = "Age (years)", y = "Count", 
          caption = "Data source: Kaggle: jessemostipak") %>%
  gf_theme(plot.title = element_text(face = "bold", size = 14, hjust = 0.5))

# Graph 3: Age comparison winners vs losers
all_ages <- data.frame(age = c(vb_clean$w_p1_age, vb_clean$l_p1_age),
                       outcome = rep(c("Winner", "Loser"), each = nrow(vb_clean)))
gf_density(~age, fill = ~outcome, data = all_ages, alpha = 0.6) %>% 
  gf_labs(title = "Older Players tend to Win their Matches More", 
          subtitle = "Density comparison between winners and losers", 
          x = "Age (years)", y = "Density", fill = "Match Outcome", 
          caption = "Data source: Kaggle: jessemostipak") %>%
  gf_theme(legend.position = "top", plot.title = element_text(face = "bold", size = 16, hjust = 0.5))

tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ–๏ธ VNL Beach 2025"),
  p("An analysis of match duration by gender reveals distinct patterns in game flow and variability. First, we notice that the mode length of a match is around 40 minutes. However, the distribution of men's match times shows a wider spread in its central portion. There seems to be greater variability as many games continue past 60 minutes but there are several short games too. In contrast, the women's data exhibits a tighter concentration around the mode, suggesting more consistent match durations and a more predictable game flow. The right tail for women's games is also significantly smaller and suggests male games can be drawn out more."),
  br(),
  p("When exploring the ages of players there is a pronounced peak within the 27-30 year range. The distribution closely approximates a bell curve, reflecting the natural attrition of athletes at both ends of the age spectrum. The comparative analysis of winners' and losers' ages reveals no significant systemic age disadvantage. In fact one could argue that as you get older your odds to win go up, explained by the accumulation of strategic experience and technical mastery.")
)
```

## **Data Source Information**

Row {data-height=300}
-----------------------------------------------------------------------

### About the Data {#datasource-beach}

```{r data-src}
tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ“‹ Data Sources"),
  tags$ul(
    tags$li(tags$strong("VNL Beach 2025:"), 
            "Beach volleyball tournament data from Kaggle", 
            tags$a(href="https://www.kaggle.com/datasets/jessemostipak/beach-volleyball", "compiled by Jesse Mostipak", target="_blank"))
  ),
  hr(),
  h4("Research Question:"),
  p("How do non-controllable factors (Gender and Age) affect match outcomes?"),
  hr(),
  p("Dashboard created with R flexdashboard โ€ข Updated: December 2025")
)
```

# **PlusLiga 2008-2023** {#liga}

## **Data Analysis Sections**

Row {data-height=450}
-----------------------------------------------------------------------

### PlusLiga 2008-2023 {data-icon="fa-chart-line"}

```{r plusliga-section}
pl_file <- find_data_file(
  primary_local = "data/Mens-Volleyball-PlusLiga-2008-2023.csv",
  backup_sample = "data/Mens-Volleyball-PlusLiga-2008-2023.csv",
  backup_original = "../../Mens-Volleyball-PlusLiga-2008-2023.csv"
)

plugliga <- read_csv(pl_file, show_col_types = FALSE)
plugliga <- plugliga %>% 
  mutate(Date = dmy_hm(Date), 
         Year = year(Date), 
         Winner = factor(Winner, levels = c(0, 1), labels = c("Team 2", "Team 1")),
         T1_Att_Eff = as.numeric(T1_Att_Eff), 
         T2_Att_Eff = as.numeric(T2_Att_Eff))

# Graph 1: Serve effectiveness comparison
gf_point(jitter(parse_number(as.character(T2_Srv_Eff))) ~ jitter(parse_number(as.character(T1_Srv_Eff))), 
         data = plugliga, color = ~Winner, alpha = 0.6) %>% 
  gf_labs(title = "Serve Efficiency doesnโ€™t Dictate Who Wins", 
          subtitle = "Jittered points with reference line of equality", 
          x = "Team 1 Serve Efficiency", y = "Team 2 Serve Efficiency", 
          caption = paste("Data: kacpergregorowicz, n =", nrow(plugliga), "matches")) %>% 
  gf_abline(slope = 1, intercept = 0, color = "gray40", linetype = "dashed", alpha = 0.5, linewidth = 1) %>%
  gf_theme(plot.title = element_text(face = "bold", size = 16, hjust = 0.5))

# Graph 2: Reception vs attack
gf_point(parse_number(as.character(T1_Att_Kill_Perc)) ~ parse_number(as.character(T1_Rec_Perf)), 
         data = plugliga, alpha = 0.6, color = "steelblue", size = 2) %>% 
  gf_labs(title = "Good Defense and Offense are Strongly Associated", 
          subtitle = "Team 1 performance metrics correlation", 
          x = "Reception Performance (%)", y = "Attack Kill Percentage (%)", 
          caption = paste("Data: kacpergregorowicz, n =", nrow(plugliga), "matches")) %>% 
  gf_smooth(method = "lm", color = "firebrick", se = TRUE, alpha = 0.2, linewidth = 1) %>%
  gf_theme(plot.title = element_text(face = "bold", size = 16, hjust = 0.5))

# Graph 3: Blocking performance Summed
gf_histogram(~(as.numeric(T1_Blk_Sum) + as.numeric(T2_Blk_Sum)), 
             data = plugliga, alpha = 0.8, binwidth = 1, fill = "firebrick", color = "white", linewidth = 0.2) %>% 
  gf_labs(title = "There are typically 14-19 Blocks in a Game", 
          subtitle = "Combined blocks from both teams (T1_Blk_Sum + T2_Blk_Sum)", 
          x = "Total Number of Blocks", y = "Frequency", 
          caption = paste("Data: kacpergregorowicz, n =", nrow(plugliga))) %>%
  gf_theme(plot.title = element_text(face = "bold", size = 16, hjust = 0.5))

tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ‡ต๐Ÿ‡ฑ PlusLiga"),
  p("While the data is drawn solely from Poland's PlusLiga, the league's consistent production of elite, internationally competitive players makes its data a valuable proxy for high-level volleyball trends. Surprisingly, there seems to be no significant difference in serve effectiveness between the two teams at any given time. This implies not only a remarkable consistency in serving performance among elite players but also that match outcomes are not dictated by serving alone."),
  br(),
  p("Furthermore, a strong positive correlation between offensive and defensive efficiency metrics highlights the sport's integrated nature. If a team has poor receives then the setter cannot get a good ball to the hitters, which puts their offense at a severe disadvantage. Conversely, failing to terminate a high-quality attack opportunity wastes defensive effort."),
  br(),
  p("Finally, blocking frequency establishes a realistic expectation for match tempo and momentum shifts. In elite volleyball, blocking is not merely passive defense but a high-risk, high-reward offensive weapon.")
)
```

## **Data Source Information**

Row {data-height=300}
-----------------------------------------------------------------------

### About the Data {#datasource-plusliga}

```{r data-sc}
tags$div(
  style = "padding: 20px;",
  h3("๐Ÿ“‹ Data Sources"),
  tags$ul(
    tags$li(tags$strong("PlusLiga 2008-2023:"), 
            "Historical league data from Kaggle", 
            tags$a(href="https://www.kaggle.com/datasets/kacpergregorowicz/-mens-volleyball-plusliga-20082022", "compiled by Kacper Gregorowicz", target="_blank"))
  ),
  hr(),
  h4("Research Question:"),
  p("What is the distribution and impact of key match statistics?"),
  hr(),
  p("Dashboard created with R flexdashboard โ€ข Updated: December 2025")
)
```