M05-Visualizing Data with Tables for MSDM CEP

Author

Juan Christian De La Cruz - Calderon

Published

February 9, 2026

1 Introduction

This report demonstrates how to create polished, presentation‑ready tables using the gt and gtExtras packages in R. It also summarizes key takeaways from the assigned videos and applies these concepts to a simulated GA4 dataset relevant to our Sacramento‑based client. The goal is to combine narrative, code, and visualization into a cohesive, professional Quarto document.

2 Essay: Tables and Data Visualization

2.1 What I Learned from the Videos

Note

The videos emphasized how the gt package provides a structured, grammar‑based approach to table building, similar to how ggplot2 structures visualizations.

The videos introduced the core philosophy behind the gt and gtExtras packages: transforming raw data into polished, presentation‑ready tables. One of the most important lessons was how gt() acts as the foundation, and each additional function layers formatting, structure, or styling on top of the table. This makes the workflow predictable and intuitive.

Another key takeaway was the value of literate programming. By combining narrative, code, and output in a single Quarto document, the analysis becomes both reproducible and easy for others to follow. This approach aligns with best practices in analytics and professional reporting.

“Tables are not just containers of numbers—they are communication tools.”
This idea was repeated throughout the videos and shaped how I now think about data presentation.

2.2 What I Liked About the gt and gtExtras Packages

I appreciated how gt makes it easy to produce tables that look polished without requiring manual formatting in Excel or PowerPoint. The syntax is clean, readable, and expressive. For example, functions like tab_header(), fmt_currency(), and tab_spanner() allow you to build a professional table step by step.

The gtExtras package adds even more value by enabling small visual elements—sparklines, bar plots, bullet charts—that would normally require separate plotting steps. These enhancements allow tables to communicate both precision and pattern, which is especially useful in business analytics.

Some features that stood out:

  • Sparklines for showing trends
  • Inline bar charts for comparing values
  • Color scales for highlighting performance
  • Quick themes that improve aesthetics

These tools make it possible to create tables that are visually appealing and analytically meaningful.

2.3 How Tables Complement Charts for Data Visualization

Charts are excellent for showing patterns, trends, and comparisons at a glance. However, they often sacrifice precision. Tables fill that gap by providing exact values and structured comparisons.

Tip

Charts show the story, but tables show the evidence.

Together, tables and charts create a complete analytical narrative:

  • Charts highlight the big picture
  • Tables provide the detailed breakdown
  • Both support different types of decision‑making

This combination is especially powerful in business contexts where stakeholders need both insight and accuracy.

2.4 When I Would Prefer Tables Over Charts

I would choose tables over charts when the goal is to communicate precision, detail, or exact comparisons. Tables are ideal when stakeholders need to look up specific values, such as:

  • Revenue
  • Conversion rates
  • Customer counts
  • KPI benchmarks

Tables are also more effective when dealing with many categories or metrics that would make a chart cluttered or difficult to interpret.

Important

Tables are essential when accuracy matters more than visual storytelling.

They are especially useful in:

  • Financial reporting
  • Operational summaries
  • KPI dashboards
  • Executive presentations

In these situations, charts alone may oversimplify the information, while tables provide clarity and structure.

3 MSDM CEP Table with gt and gtExtras

This section demonstrates how to create a polished, presentation‑ready table using GA4‑style engagement metrics for our Sacramento‑based client. Since the real GA4 data lives online, we simulate a small dataset in R to illustrate the workflow.

Note

The goal is to combine traffic, engagement, and intent metrics in one table to support our analytics objectives.

3.1 Loading Packages and Creating a Mock GA4 Dataset

library(tidyverse)
library(gt)
library(gtExtras)

# Mock GA4 dataset representing device performance
msdm <- tibble(
  device_category = c("desktop", "mobile", "tablet"),
  total_visits = c(6100, 15000, 1800),
  ticket_clicks = c(420, 680, 90),
  ppv_clicks = c(210, 330, 40),
  revenue = c(54000, 72000, 9000),
  revenue_spark = list(
    c(8000, 12000, 16000, 18000),
    c(15000, 18000, 20000, 19000),
    c(2000, 2500, 2200, 2300)
  )
)

3.2 Preparing the Data

summary_tbl <- msdm %>%
  group_by(device_category) %>%
  summarise(
    total_visits = sum(total_visits),
    ticket_clicks = sum(ticket_clicks),
    ppv_clicks = sum(ppv_clicks),
    revenue = sum(revenue),
    revenue_spark = revenue_spark
  )

3.3 Creating the Table

GA4 Engagement Metrics by Device Category
Total visits, ticket clicks, and PPV clicks for our Sacramento client
Device Category
Engagement Metrics
Revenue ($) Revenue Trend
Total Visits Ticket Clicks1 PPV Clicks
desktop 6,100 420 210 $54,000.00 18.0K
mobile 15,000 680 330 $72,000.00 19.0K
tablet 1,800 90 40 $9,000.00 2.3K
1 Ticket clicks and PPV clicks represent key engagement actions.
Source: Simulated GA4 dataset for MSDM CEP project
Warning: Since gt v0.9.0, the `colors` argument has been deprecated.
• Please use the `fn` argument instead.
This warning is displayed once every 8 hours.
Revenue Highlight Table
Color scale applied to total revenue
total_visits ticket_clicks ppv_clicks revenue revenue_spark
desktop 6100 420 210 $54,000.00 8000, 12000, 16000, 18000
mobile 15000 680 330 $72,000.00 15000, 18000, 20000, 19000
tablet 1800 90 40 $9,000.00 2000, 2500, 2200, 2300

4 Conclusion

This workshop reinforced how powerful tables can be when communicating analytical insights. Using the gt and gtExtras packages made it possible to create clean, professional tables that combine exact values with visual cues such as sparklines and color scales. These tools make it easier to present GA4 metrics in a way that is both informative and visually engaging. Overall, the table created for this assignment directly supports the goals of my MSDM CEP project by summarizing key engagement behaviors and highlighting device‑level differences that matter for decision‑making.