---
title: "Package Data"
---
```{r}
#| include: false
library(tabviz)
library(dplyr)
library(tidyr)
```
tabviz includes five datasets for examples, testing, and learning. Each is designed to showcase different features and use cases.
## Available Datasets
| Dataset | Rows | Domain | Key Features |
|---------|------|--------|--------------|
| `glp1_trials` | 24 | Clinical trials | HR/CI, groups, subgroups, summary rows |
| `airline_delays` | 40 | Transportation | Sparkline trends, bar charts, grouped |
| `nba_efficiency` | 30 | Sports | Player stats, conference groups, badges |
| `climate_temps` | 20 | Science | Minimal structure, uncertainty ranges |
| `effect_sizes` | 20 | Stress test | Extreme CIs, split testing, regions/outcomes |
---
## glp1_trials
GLP-1 agonist cardiovascular outcomes trials—ideal for meta-analysis examples.
```{r}
data(glp1_trials)
glimpse(glp1_trials)
```
**Best for:** Meta-analyses, subgroup analyses, publication-style forest plots
### Example
```{r}
#| fig-height: 6
glp1_trials |>
filter(group == "Main Trials") |>
tabviz(
label = "study",
columns = list(
col_text("drug", "Drug"),
col_n("n"),
col_interval("HR (95% CI)", point = "hr", lower = "lower", upper = "upper"),
viz_forest(point = "hr", lower = "lower", upper = "upper",
scale = "log", null_value = 1, axis_label = "Hazard Ratio")
),
theme = web_theme_lancet(),
title = "GLP-1 Agonist Cardiovascular Outcomes"
)
```
### Variables
| Variable | Description |
|----------|-------------|
| `study` | Trial name and year |
| `drug` | GLP-1 agonist name |
| `hr`, `lower`, `upper` | Hazard ratio and 95% CI |
| `n`, `events` | Sample size and event count |
| `pvalue` | P-value |
| `group` | Trial grouping (Main Trials, Subgroups) |
| `row_type`, `row_bold` | Pre-computed row styling |
---
## airline_delays
Airline carrier performance data with trends—ideal for sparklines and bar charts.
```{r}
data(airline_delays)
glimpse(airline_delays)
```
**Best for:** Sparkline columns, bar charts, grouped comparisons
### Example
```{r}
airline_summary <- airline_delays |>
group_by(carrier) |>
summarise(
delay_vs_avg = mean(delay_vs_avg),
delay_lower = mean(delay_lower),
delay_upper = mean(delay_upper),
on_time_pct = mean(on_time_pct),
trend = list(unlist(trend[1]))
)
tabviz(
airline_summary,
label = "carrier",
columns = list(
col_percent("on_time_pct", "On-Time %"),
col_sparkline("trend", "12M Trend"),
col_interval("Delay (95% CI)", point = "delay_vs_avg", lower = "delay_lower", upper = "delay_upper"),
viz_forest(point = "delay_vs_avg", lower = "delay_lower", upper = "delay_upper",
null_value = 0, axis_label = "Delay vs. Average (minutes)")
),
theme = web_theme_modern(),
title = "Airline Carrier Performance"
)
```
### Variables
| Variable | Description |
|----------|-------------|
| `carrier` | Airline name |
| `delay_vs_avg`, `delay_lower`, `delay_upper` | Delay vs industry average and 95% CI |
| `on_time_pct` | Proportion of on-time arrivals (0-1) |
| `satisfaction` | Customer satisfaction (1-5) |
| `flights` | Number of flights |
| `trend` | List-column with 12-month delay trend |
| `carrier_type` | Carrier category (Major, Regional, Budget) |
---
## nba_efficiency
NBA player statistics—a fun dataset for demonstrating grouped data and badges.
```{r}
data(nba_efficiency)
glimpse(nba_efficiency)
```
**Best for:** Grouped data, badges, non-medical examples
### Example
```{r}
#| fig-height: 7
tabviz(
nba_efficiency,
label = "player",
group = "conference",
columns = list(
col_text("team", "Team", width = 60),
col_numeric("ppg", "PPG"),
col_interval("PER (95% CI)", point = "per", lower = "per_lower", upper = "per_upper"),
viz_forest(point = "per", lower = "per_lower", upper = "per_upper",
null_value = 15, axis_label = "Player Efficiency Rating")
),
row_badge = "award",
theme = web_theme_modern(),
title = "NBA Player Efficiency",
subtitle = "2023-24 Season",
caption = "PER: 15 = league average"
)
```
### Variables
| Variable | Description |
|----------|-------------|
| `player` | Player name |
| `team`, `position` | Team abbreviation and position |
| `conference` | Eastern or Western |
| `per`, `per_lower`, `per_upper` | Player Efficiency Rating and 95% CI |
| `ppg`, `games` | Points per game and games played |
| `award` | Major awards (MVP, DPOY, etc.) for badge display |
---
## climate_temps
Regional temperature anomalies—minimal dataset for clean examples.
```{r}
data(climate_temps)
glimpse(climate_temps)
```
**Best for:** Simple examples, minimal themes, uncertainty visualization
### Example
```{r}
climate_temps |>
filter(category %in% c("Global", "Hemisphere", "Continental")) |>
tabviz(
label = "region",
group = "category",
columns = list(
col_text("certainty", "Confidence"),
col_interval("Anomaly (95% CI)", point = "anomaly", lower = "lower", upper = "upper"),
viz_forest(point = "anomaly", lower = "lower", upper = "upper",
null_value = 0, axis_label = "Temperature Anomaly (°C)")
),
theme = web_theme_minimal(),
title = "Regional Temperature Anomalies",
subtitle = "2023 vs. Pre-Industrial Baseline"
)
```
### Variables
| Variable | Description |
|----------|-------------|
| `region` | Geographic region name |
| `category` | Region type (Global, Hemisphere, Continental, Ocean) |
| `anomaly`, `lower`, `upper` | Temperature anomaly and uncertainty |
| `certainty` | Confidence level (High, Medium, Low) |
---
## effect_sizes
A stress-test dataset designed to test forest plot axis rendering with varying confidence interval widths.
```{r}
data(effect_sizes)
glimpse(effect_sizes)
```
**Best for:** Testing axis calculation, split views, extreme CIs, multi-forest columns
### Example
```{r}
# Group by region and show effect sizes with marker styling
effect_sizes |>
filter(outcome == "Primary") |>
tabviz(
label = "study",
group = "region",
columns = list(
col_n("n"),
viz_forest(point = "hr", lower = "lower", upper = "upper",
scale = "log", null_value = 1, width = 200)
),
marker_color = ~ ifelse(significant, "#16a34a", "#94a3b8"),
theme = web_theme_modern(),
title = "Effect Sizes by Region"
)
```
### Variables
| Variable | Description |
|----------|-------------|
| `study` | Study or site name |
| `region` | Geographic region (North America, Europe, Asia Pacific) |
| `outcome` | Outcome type (Primary, Secondary, Exploratory) |
| `treatment` | Treatment arm |
| `hr`, `lower`, `upper` | Hazard ratio and 95% CI |
| `significant` | Whether CI excludes 1.0 |
| `direction` | Effect direction (Favors Treatment, Favors Control) |
---
## Using Datasets
All datasets are lazy-loaded. Simply reference them after loading the package:
```r
library(tabviz)
# Datasets are available immediately
head(glp1_trials)
# Or explicitly load
data(glp1_trials)
```
### Documentation
See help files for full variable descriptions:
- `?glp1_trials`
- `?airline_delays`
- `?nba_efficiency`
- `?climate_temps`
---
## See Also
- [Gallery](../gallery-basic.qmd) — Full examples using these datasets
- [Columns](columns.qmd) — Column types for displaying data
- [Themes](themes.qmd) — Theme options for styling