• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Python Viz
  • Seaborn
  • Altair
  • R Viz
  • ggplot2
  • About
    • Privacy Policy
  • Show Search
Hide Search

How to Make Beautiful Tables with gtExtras

datavizpyr · September 23, 2021 ·

A well made table showing the summary of the data is under utilized. gt() package available as part of tidyverse improves the look of a table and makes it easy to read and understand.

If you think gt is cool, wait until you see the work of Thomas Mock. Thomas Mock has created the fantastic R package gtExtras, that takes your tables to next level :). Just came across a Thomas Mock’s tweet on making a beautiful table with just a five lines R code.

Here is working through his code using tidytuesday dataset on Emmy Awards and Nominees. We will use the summarized version of the data to visualize the producers and their Win/nomination of Emmy awards.

library(tidyverse)
library(palmerpenguins)
theme_set(theme_bw(16))

Let us use the summarized data from Emmy awards to make a table.

p2data <- "https://raw.githubusercontent.com/datavizpyr/data/master/Emmy_awards_summary_tidytuesday.tsv"
stream_data <- read_tsv(p2data)
stream_data

## # A tibble: 9 × 5
##   distributor type   Ratio Nominee Winner
##   <chr>       <chr>  <dbl>   <dbl>  <dbl>
## 1 Netflix     wifi  0.277      224     62
## 2 HBO         video 0.288      156     45
## 3 NBC         tv    0.205       78     16
## 4 ABC         tv    0.16        50      8
## 5 Hulu        wifi  0.02        50      1
## 6 FX Networks video 0.111       45      5
## 7 Prime Video wifi  0.0889      45      4
## 8 Apple TV+   wifi  0.238       42     10
## 9 CBS         tv    0.025       40      1
stream_data %>% 
  gt()
Simple table with gt()
Simple table with gt()

We can use gtExtras’ function to add a plot showing the numbers in a column in the table.

stream_data %>% 
  gt() %>% 
  gt_plt_bullet(column = Nominee, target = Winner) 
Customizing gt() table with gtExtras
Customizing gt() table with gtExtras

Let us add company icon image in the table for company names.

stream_data %>% 
  gt() %>% 
  gt_plt_bullet(column = Nominee, target = Winner) %>% 
  gt_fa_column(column = type)
Adding icons to table with gtExtras
Adding icons to table with gtExtras

Let us use NYTimes themes to the table.

stream_data %>% 
  gt() %>% 
  gt_plt_bullet(column = Nominee, target = Winner) %>% 
  gt_fa_column(column = type) %>% 
  gt_theme_nytimes()
gtExtras table NY Times theme
gtExtras table NY Times theme

Here we format the digits.

stream_data %>% 
  gt() %>% 
  gt_plt_bullet(column = Nominee, target = Winner) %>% 
  gt_fa_column(column = type) %>% 
  gt_theme_nytimes() %>% 
  fmt_symbol_first(column = Ratio, suffix = "%", 
                   decimals = 1, scale_by = 100)
Customizing tables with gtExtras
Customizing tables with gtExtras

Related posts:

How to Make Heatmap with ggplot2?How To Make Simple Heatmaps with ggplot2 in R? Stacked Barplots Side By Side with ggplot2 in RHow to Make Horizontal Stacked Barplots with ggplot2 in R? Scatter Plot R: Fill color by variableHow To Color Scatter Plot by Variable in R with ggplot2? How to Align Title Position in ggplot2?How To Adjust Title Position in ggplot2 ?

Filed Under: gtExtras, R Tagged With: table with gtExtras

Primary Sidebar

Tags

Altair barplot Boxplot boxplot python boxplot with jiitered text labels Bubble Plot Color Palette Countplot Density Plot Facet Plot gganimate ggplot2 ggplot2 Boxplot ggplot2 error ggplot boxplot ggridges ggtext element_markdown() Grouped Barplot R heatmap heatmaps Histogram Histograms Horizontal boxplot Python lollipop plot Maps Matplotlib Pandas patchwork pheatmap Pyhon Python R RColorBrewer reorder boxplot ggplot Ridgeline plot Scatter Plot Scatter Plot Altair Seaborn Seaborn Boxplot Stock Price Over Time Stripplot UpSetR Violinplot Violin Plot World Map ggplot2

Buy Me a Coffee

Copyright © 2025 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version