• Steven Ponce
  • About
  • Data Visualizations
  • Projects
  • Resume
  • Email

On this page

  • Original
  • Makeover
  • Steps to Create this Graphic
    • 1. Load Packages & Setup
    • 2. Read in the Data
    • 3. Examine the Data
    • 4. Tidy Data
    • 5. Visualization Parameters
    • 6. Plot
    • 7. Save
    • 8. Session Info
    • 9. GitHub Repository
    • 10. References
    • 11. Custom Functions Documentation

The World’s Fastest Cars: Some Sell Engineering, Others Sell Exclusivity

  • Show All Code
  • Hide All Code

  • View Source

Top: deviation from the median in cost per horsepower and speed delivered per horsepower. Burgundy = worse value; steel blue = better value. Bottom: the same cars by units produced. Each filled square = one car built.

MakeoverMonday
Data Visualization
R Programming
2026
Redesigning a raw data table into a two-panel patchwork: diverging bars comparing cost vs. speed efficiency per horsepower, paired with a unit chart showing the extreme scarcity of each model.
Author

Steven Ponce

Published

March 17, 2026

Original

The original visualization comes from Fastest Cars in the World (2026)

Original visualization

Makeover

Figure 1: A three-panel chart about the world’s fastest cars. The top two panels are diverging bar charts showing deviation from the median in cost per horsepower (left) and speed per horsepower (right). Burgundy bars indicate worse value; steel blue indicates better value. The Bugatti Chiron SS 300+ is the most expensive per horsepower at +$1,151 above median, while the Rimac C Two and Hennessey models sit below median cost. The bottom panel is a waffle chart showing the total units produced for all eight cars. Each dark gray square represents one car built against a light gray grid of equal size, making rarity directly comparable. The Rimac C Two leads with 150 units; the Hennessey Venom GT is the rarest at just 13 units.

Steps to Create this Graphic

1. Load Packages & Setup

Show code
```{r}
#| label: load
#| warning: false
#| message: false      
#| results: "hide"     

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
  if (!require("pacman")) install.packages("pacman")
  pacman::p_load(
    tidyverse, ggtext, showtext, scales, 
  glue, janitor, readxl, patchwork   
)
})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 14,
  height = 11,
  units  = "in",
  dpi    = 320
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

2. Read in the Data

Show code
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
#| 

df_raw <- readxl::read_xlsx(
  here::here("data/MakeoverMonday/2026/The fastest cars.xlsx")) |>
  clean_names()
```

3. Examine the Data

Show code
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(df_raw)
skimr::skim_without_charts(df_raw)
```

4. Tidy Data

Show code
```{r}
#| label: tidy
#| warning: false

df <- df_raw |>
  rename(
    top_speed_kmh = top_speed_km_h,
    hp            = horsepower_hp,
    torque        = torque_lb_ft,
    accel_sec     = x0_100_km_h_approximate_in_sec,
    units         = units_produced,
    price_per_hp  = price_per_hp_usd,
    speed_per_hp  = speed_per_hp_km_h_per_hp
  ) |>
  mutate(
    car_label = case_when(
      car == "Hennessey Venom F5"              ~ "Hennessey Venom F5",
      car == "Bugatti Chiron Super Sport 300+" ~ "Bugatti Chiron SS 300+",
      car == "SSC Tuatara"                     ~ "SSC Tuatara",
      car == "Koenigsegg Jesko"                ~ "Koenigsegg Jesko",
      car == "Koenigsegg Agera RS"             ~ "Koenigsegg Agera RS",
      car == "Hennessey Venom GT"              ~ "Hennessey Venom GT",
      car == "Bugatti Veyron 16.4 Super Sport" ~ "Bugatti Veyron SS",
      car == "Rimac C Two"                     ~ "Rimac C Two"
    ),
    car_short = case_when(
      car == "Hennessey Venom F5"              ~ "Venom F5",
      car == "Bugatti Chiron Super Sport 300+" ~ "Chiron SS 300+",
      car == "SSC Tuatara"                     ~ "Tuatara",
      car == "Koenigsegg Jesko"                ~ "Jesko",
      car == "Koenigsegg Agera RS"             ~ "Agera RS",
      car == "Hennessey Venom GT"              ~ "Venom GT",
      car == "Bugatti Veyron 16.4 Super Sport" ~ "Veyron SS",
      car == "Rimac C Two"                     ~ "C Two"
    )
  )
```

5. Visualization Parameters

Show code
```{r}
#| label: params
#| include: true
#| warning: false

### |- Colors ----
colors <- get_theme_colors(
  palette = list(
    burgundy      = "#6D1A36",
    steel         = "#4A6FA5",
    neutral_dark  = "#2B2B2B",
    neutral_mid   = "#6B6B6B",
    neutral_light = "#E5E5E5",
    grid_light    = "#D9D9D9",
    empty_tile    = "#F0F0F0"
  )
)

### |- Titles and caption ----
title_text <- "The World's Fastest Cars: Some Sell Engineering, Others Sell Exclusivity"

subtitle_text <- glue(
  "Top: deviation from the median in <b>cost per horsepower</b> and ",
  "<b>speed delivered per horsepower</b>. ",
  "<span style='color:{colors$palette$burgundy}'>Burgundy</span> = worse value; ",
  "<span style='color:{colors$palette$steel}'>steel blue</span> = better value.<br>",
  "Bottom: the same cars by <b>units produced</b>. Each filled square = one car built."
)

caption_text <- create_mm_caption(
  mm_year     = 2026,
  mm_week     = 11,
  source_text = "RankRed.com · data.world/makeovermonday"
)

### |- fonts ----
setup_fonts()
fonts <- get_font_families()

### |- plot theme ----
base_theme <- create_base_theme(colors)

weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    panel.grid.major.x = element_line(color = colors$palette$grid_light, linewidth = 0.3),
    panel.grid.major.y = element_blank(),
    axis.ticks         = element_blank(),
    axis.text.x        = element_text(size = 9, color = colors$palette$neutral_mid),
    axis.text.y        = element_text(size = 10, color = colors$palette$neutral_mid),
    axis.title         = element_blank(),
    plot.title = element_text(
      size = rel(1.25), family = fonts$title, face = "bold",
      color = colors$palette$neutral_dark, lineheight = 1.05,
      margin = margin(t = 3, b = 4)
    ),
    plot.subtitle = element_text(
      size = rel(0.8), family = fonts$subtitle,
      color = colors$palette$neutral_mid, lineheight = 1.1,
      margin = margin(t = 0, b = 8)
    )
  )
)

theme_set(weekly_theme)
```

6. Plot

Show code
```{r}
#| label: plot
#| warning: false

### |- PANEL A: Diverging Bars — Luxury Premium vs. Engineering Efficiency ----

# Derived Data ----
med_price_hp <- median(df$price_per_hp)
med_speed_hp <- median(df$speed_per_hp)

plot_df <- df |>
  mutate(
    price_hp_dev = price_per_hp - med_price_hp,
    speed_hp_dev = speed_per_hp - med_speed_hp,
    cost_flag    = if_else(price_hp_dev > 0, "Above median cost", "Below median cost"),
    eff_flag     = if_else(speed_hp_dev > 0, "Above median efficiency", "Below median efficiency")
  ) |>
  arrange(desc(price_hp_dev)) |>
  mutate(car_order = factor(car_short, levels = rev(car_short)))

### |-  left panel: cost per HP ----
p_cost <- plot_df |>
  ggplot(aes(x = price_hp_dev, y = car_order, fill = cost_flag)) +
  geom_col(width = 0.62) +
  geom_vline(xintercept = 0, linewidth = 0.6, color = colors$palette$neutral_dark) +
  geom_text(
    aes(
      label = if_else(price_hp_dev > 0,
                      paste0("+", dollar(round(price_hp_dev))),
                      dollar(round(price_hp_dev))),
      x = if_else(price_hp_dev > 0, price_hp_dev + 28, price_hp_dev - 28)
    ),
    size = 3,
    color = colors$palette$neutral_dark,
    fontface = "bold",
    hjust = if_else(plot_df$price_hp_dev > 0, 0, 1)
  ) +
  annotate(
    "segment",
    x = 0, xend = 0, y = 0.55, yend = 1.15,
    color = colors$palette$neutral_mid, linewidth = 0.35, linetype = 2
  ) +
  annotate(
    "text",
    x = 20, y = 0.95,
    label = glue("median = {dollar(round(med_price_hp))}/HP"),
    hjust = 0, size = 2.7,
    color = colors$palette$neutral_mid, fontface = "italic"
  ) +
  scale_fill_manual(
    values = c(
      "Above median cost" = colors$palette$burgundy,
      "Below median cost" = colors$palette$steel
    ),
    guide = "none"
  ) +
  scale_x_continuous(
    labels = label_dollar(),
    limits = c(-520, 1325),
    expand = expansion(mult = c(0, 0))
  ) +
  labs(
    title    = "Cost per horsepower",
    subtitle = "Deviation from median ($/HP) · sorted most to least expensive"
  ) +
  theme(
    plot.title    = element_text(size = rel(1.0), face = "bold"),
    plot.subtitle = element_text(size = rel(0.76), margin = margin(b = 8)),
    axis.text.y   = element_text(color = colors$palette$neutral_mid)
  )

### |-  right panel: speed per HP ----
p_speed <- plot_df |>
  ggplot(aes(x = speed_hp_dev, y = car_order, fill = eff_flag)) +
  geom_col(width = 0.62) +
  geom_vline(xintercept = 0, linewidth = 0.6, color = colors$palette$neutral_dark) +
  geom_text(
    aes(
      label = if_else(speed_hp_dev > 0,
                      paste0("+", number(speed_hp_dev, accuracy = 0.001)),
                      number(speed_hp_dev, accuracy = 0.001)),
      x = if_else(speed_hp_dev > 0, speed_hp_dev + 0.004, speed_hp_dev - 0.004)
    ),
    size = 3,
    color = colors$palette$neutral_dark,
    fontface = "bold",
    hjust = if_else(plot_df$speed_hp_dev > 0, 0, 1)
  ) +
  annotate(
    "segment",
    x = 0, xend = 0, y = 0.55, yend = 1.15,
    color = colors$palette$neutral_mid, linewidth = 0.35, linetype = 2
  ) +
  annotate(
    "text",
    x = 0.002, y = 0.95,
    label = glue("median = {number(med_speed_hp, accuracy = 0.001)} km/h/HP"),
    hjust = 0, size = 2.7,
    color = colors$palette$neutral_mid, fontface = "italic"
  ) +
  scale_fill_manual(
    values = c(
      "Above median efficiency" = colors$palette$steel,
      "Below median efficiency" = colors$palette$burgundy
    ),
    guide = "none"
  ) +
  scale_x_continuous(
    labels = label_number(accuracy = 0.01),
    limits = c(-0.10, 0.07),
    expand = expansion(mult = c(0, 0))
  ) +
  labs(
    title    = "Speed per horsepower",
    subtitle = "Deviation from median (km/h per HP) · same car order as left panel"
  ) +
  theme(
    plot.title    = element_text(size = rel(1.0), face = "bold"),
    plot.subtitle = element_text(size = rel(0.76), margin = margin(b = 8)),
    axis.text.y   = element_blank()
  )

### |- PANEL B: Unit Chart — How Many Were Ever Built? ----

# Derived Data ----
rarity_base <- df |>
  transmute(
    car_short,
    units,
    facet_label = glue("{car_short}\n{units} units")
  ) |>
  arrange(desc(units)) |>
  mutate(facet_label = factor(facet_label, levels = facet_label))

max_units <- max(rarity_base$units)
n_cols    <- 15
n_rows    <- ceiling(max_units / n_cols)

rarity_full <- rarity_base |>
  rowwise() |>
  reframe(
    car_short   = car_short,
    facet_label = facet_label,
    units       = units,
    unit_id     = seq_len(n_cols * n_rows)
  ) |>
  mutate(
    filled = unit_id <= units,
    col    = (unit_id - 1) %% n_cols + 1,
    row    = (unit_id - 1) %/% n_cols + 1
  )

### |-  unit chart ----
p_rarity <- rarity_full |>
  ggplot(aes(x = col, y = -row, fill = filled)) +
  geom_tile(width = 0.8, height = 0.8, color = "white", linewidth = 0.45) +
  facet_wrap(~facet_label, ncol = 4) +
  scale_fill_manual(
    values = c("TRUE" = "#4A4A4A", "FALSE" = "#E8E8E8"),
    guide  = "none"   # filled vs. empty is self-evident; no legend needed
  ) +
  labs(
    title    = "How many were ever built?",
    subtitle = "Each square represents one car. Common empty grid makes rarity comparable across models."
  ) +
  coord_equal() +
  theme(
    axis.text.x        = element_blank(),
    axis.text.y        = element_blank(),
    axis.line          = element_blank(),
    panel.grid         = element_blank(),
    panel.grid.major   = element_blank(),
    panel.grid.minor   = element_blank(),
    panel.grid.major.x = element_blank(),
    strip.text = element_text(
      size = rel(0.8), face = "bold",
      color = colors$palette$neutral_dark,
      lineheight = 1.3
    ),
    panel.spacing   = unit(1.1, "lines"),
    legend.position = "none"
  )

### |-  Combined Plots ----
p_top <- p_cost + p_speed + plot_layout(widths = c(1.15, 1))

combined_plots <- p_top / p_rarity +
  plot_layout(heights = c(1.05, 1)) +
  plot_annotation(
    title    = title_text,
    subtitle = subtitle_text,
    caption  = caption_text,
    theme = theme(
      plot.title = element_text(
        size = rel(1.42), face = "bold",
        color = colors$palette$neutral_dark,
        margin = margin(b = 5)
      ),
      plot.subtitle = element_markdown(
        size = rel(0.88),
        color = colors$palette$neutral_mid,
        lineheight = 1.15,
        margin = margin(b = 12)
      ),
      plot.caption = element_markdown(
        size = rel(0.70),
        color = colors$palette$neutral_mid,
        hjust = 0
      ),
      plot.margin = margin(t = 14, r = 16, b = 12, l = 16)
    )
  )
```

7. Save

Show code
```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plots, 
  type = "makeovermonday", 
  year = current_year,
  week = current_week,
  width = 14, 
  height = 11
  )
```

8. Session Info

TipExpand for Session Info
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] here_1.0.2      patchwork_1.3.2 readxl_1.4.5    janitor_2.2.1  
 [5] glue_1.8.0      scales_1.4.0    showtext_0.9-7  showtextdb_3.0 
 [9] sysfonts_0.8.9  ggtext_0.1.2    lubridate_1.9.5 forcats_1.0.1  
[13] stringr_1.6.0   dplyr_1.2.0     purrr_1.2.1     readr_2.2.0    
[17] tidyr_1.3.2     tibble_3.2.1    ggplot2_4.0.2   tidyverse_2.0.0
[21] pacman_0.5.1   

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       xfun_0.56          htmlwidgets_1.6.4  tzdb_0.5.0        
 [5] vctrs_0.7.1        tools_4.3.1        generics_0.1.4     yulab.utils_0.2.4 
 [9] curl_7.0.0         pkgconfig_2.0.3    ggplotify_0.1.3    RColorBrewer_1.1-3
[13] S7_0.2.0           lifecycle_1.0.5    compiler_4.3.1     farver_2.1.2      
[17] codetools_0.2-19   snakecase_0.11.1   litedown_0.9       htmltools_0.5.9   
[21] yaml_2.3.10        pillar_1.10.2      magick_2.8.6       commonmark_2.0.0  
[25] tidyselect_1.2.1   digest_0.6.37      stringi_1.8.7      labeling_0.4.3    
[29] rprojroot_2.1.1    fastmap_1.2.0      grid_4.3.1         cli_3.6.4         
[33] magrittr_2.0.3     withr_3.0.2        rappdirs_0.3.4     timechange_0.4.0  
[37] rmarkdown_2.30     otel_0.2.0         cellranger_1.1.0   hms_1.1.4         
[41] evaluate_1.0.5     knitr_1.51         markdown_2.0       gridGraphics_0.5-1
[45] rlang_1.1.7        gridtext_0.1.6     Rcpp_1.1.1         xml2_1.5.2        
[49] rstudioapi_0.18.0  jsonlite_2.0.0     R6_2.6.1           fs_1.6.6          

9. GitHub Repository

TipExpand for GitHub Repo

The complete code for this analysis is available in mm_2026_11.qmd.

For the full repository, click here.

10. References

TipExpand for References

Primary Data (Makeover Monday): 1. Makeover Monday 2026 Week 11: 8 Fastest Cars in the World (2026) 2. Original Article: Fastest Cars in the World - Source: RankRed - Coverage: Top 8 fastest production cars as of 2026, including speed, power, price, and production figures

Source Data: 3. Dataset: 2026 Week 11 — 8 Fastest Cars in the World - Source: RankRed via data.world/makeovermonday - Data includes: Car name, manufacturer, country, engine type, top speed (mph and km/h), horsepower, torque, 0–100 km/h time, price (USD), units produced, price per HP, and speed per HP - Scope: 8 production cars ranked by verified top speed as of 2026

Note: All values are reported directly from the source. Deviation from median was computed for price per HP and speed per HP to enable the diverging bar comparison. No external data sources, price deflators, or population adjustments were applied.

11. Custom Functions Documentation

Note📦 Custom Helper Functions

This analysis uses custom functions from my personal module library for efficiency and consistency across projects.

Functions Used:

  • fonts.R: setup_fonts(), get_font_families() - Font management with showtext
  • social_icons.R: create_social_caption() - Generates formatted social media captions
  • image_utils.R: save_plot() - Consistent plot saving with naming conventions
  • base_theme.R: create_base_theme(), extend_weekly_theme(), get_theme_colors() - Custom ggplot2 themes

Why custom functions?
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.

Source Code:
View all custom functions → GitHub: R/utils

Back to top

Citation

BibTeX citation:
@online{ponce2026,
  author = {Ponce, Steven},
  title = {The {World’s} {Fastest} {Cars:} {Some} {Sell} {Engineering,}
    {Others} {Sell} {Exclusivity}},
  date = {2026-03-17},
  url = {https://stevenponce.netlify.app/data_visualizations/MakeoverMonday/2026/mm_2026_11.html},
  langid = {en}
}
For attribution, please cite this work as:
Ponce, Steven. 2026. “The World’s Fastest Cars: Some Sell Engineering, Others Sell Exclusivity.” March 17, 2026. https://stevenponce.netlify.app/data_visualizations/MakeoverMonday/2026/mm_2026_11.html.
Source Code
---
title: "The World's Fastest Cars: Some Sell Engineering, Others Sell Exclusivity"
subtitle: "Top: deviation from the median in cost per horsepower and speed delivered per horsepower. Burgundy = worse value; steel blue = better value. Bottom: the same cars by  units produced. Each filled square = one car built."
description: "Redesigning a raw data table into a two-panel patchwork: diverging bars comparing cost vs. speed efficiency per horsepower, paired with a unit chart showing the extreme scarcity of each model."
date: "2026-03-17"
author:
  - name: "Steven Ponce"
    url: "https://stevenponce.netlify.app"
citation:
  url: "https://stevenponce.netlify.app/data_visualizations/MakeoverMonday/2026/mm_2026_11.html"
categories: ["MakeoverMonday", "Data Visualization", "R Programming", "2026"]   
tags: [
  "makeover-monday",
  "data-visualization",
  "ggplot2",
  "patchwork",
  "diverging-bar-chart",
  "unit-chart",
  "automotive",
  "hypercars",
  "engineering",
  "performance-metrics",
  "scarcity",
  "2026"
]
image: "thumbnails/mm_2026_11.png"
format:
  html:
    toc: true
    toc-depth: 5
    code-link: true
    code-fold: true
    code-tools: true
    code-summary: "Show code"
    self-contained: true
    theme: 
      light: [flatly, assets/styling/custom_styles.scss]
      dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options: 
  chunk_output_type: inline
execute: 
  freeze: true                                      
  cache: true                                       
  error: false
  message: false
  warning: false
  eval: true
editor: 
  markdown: 
    wrap: 72
---

```{r}
#| label: setup-links
#| include: false

# CENTRALIZED LINK MANAGEMENT

## Project-specific info 
current_year <- 2026
current_week <- 11
project_file <- "mm_2026_11.qmd"
project_image <- "mm_2026_11.png"

## Data Sources
data_main <- "https://data.world/makeovermonday/8-fastest-cars-in-the-world-as-of-2026"
data_secondary <- "https://data.world/makeovermonday/8-fastest-cars-in-the-world-as-of-2026"

## Repository Links  
repo_main <- "https://github.com/poncest/personal-website/"
repo_file <- paste0("https://github.com/poncest/personal-website/blob/master/data_visualizations/MakeoverMonday/", current_year, "/", project_file)

## External Resources/Images
chart_original <- "https://raw.githubusercontent.com/poncest/MakeoverMonday/refs/heads/master/2026/Week_11/original_chart.png"

## Organization/Platform Links
org_primary <- "https://www.rankred.com/fastest-cars-in-the-world/"
org_secondary <- "https://www.rankred.com/fastest-cars-in-the-world/"

# Helper function to create markdown links
create_link <- function(text, url) {
  paste0("[", text, "](", url, ")")
}

# Helper function for citation-style links
create_citation_link <- function(text, url, title = NULL) {
  if (is.null(title)) {
    paste0("[", text, "](", url, ")")
  } else {
    paste0("[", text, "](", url, ' "', title, '")')
  }
}
```

### Original

The original visualization comes from `r create_link("Fastest Cars in the World (2026)", data_secondary)`

![Original visualization](https://raw.githubusercontent.com/poncest/MakeoverMonday/refs/heads/master/2026/Week_11/original_chart.png)

### Makeover

![A three-panel chart about the world's fastest cars. The top two panels are diverging bar charts showing deviation from the median in cost per horsepower (left) and speed per horsepower (right). Burgundy bars indicate worse value; steel blue indicates better value. The Bugatti Chiron SS 300+ is the most expensive per horsepower at +$1,151 above median, while the Rimac C Two and Hennessey models sit below median cost. The bottom panel is a waffle chart showing the total units produced for all eight cars. Each dark gray square represents one car built against a light gray grid of equal size, making rarity directly comparable. The Rimac C Two leads with 150 units; the Hennessey Venom GT is the rarest at just 13 units.](mm_2026_11.png){#fig-1}

### [**Steps to Create this Graphic**]{.mark}

#### [1. Load Packages & Setup]{.smallcaps}

```{r}
#| label: load
#| warning: false
#| message: false      
#| results: "hide"     

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
  if (!require("pacman")) install.packages("pacman")
  pacman::p_load(
    tidyverse, ggtext, showtext, scales, 
  glue, janitor, readxl, patchwork   
)
})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 14,
  height = 11,
  units  = "in",
  dpi    = 320
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

#### [2. Read in the Data]{.smallcaps}

```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
#| 

df_raw <- readxl::read_xlsx(
  here::here("data/MakeoverMonday/2026/The fastest cars.xlsx")) |>
  clean_names()
```

#### [3. Examine the Data]{.smallcaps}

```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(df_raw)
skimr::skim_without_charts(df_raw)
```

#### [4. Tidy Data]{.smallcaps}

```{r}
#| label: tidy
#| warning: false

df <- df_raw |>
  rename(
    top_speed_kmh = top_speed_km_h,
    hp            = horsepower_hp,
    torque        = torque_lb_ft,
    accel_sec     = x0_100_km_h_approximate_in_sec,
    units         = units_produced,
    price_per_hp  = price_per_hp_usd,
    speed_per_hp  = speed_per_hp_km_h_per_hp
  ) |>
  mutate(
    car_label = case_when(
      car == "Hennessey Venom F5"              ~ "Hennessey Venom F5",
      car == "Bugatti Chiron Super Sport 300+" ~ "Bugatti Chiron SS 300+",
      car == "SSC Tuatara"                     ~ "SSC Tuatara",
      car == "Koenigsegg Jesko"                ~ "Koenigsegg Jesko",
      car == "Koenigsegg Agera RS"             ~ "Koenigsegg Agera RS",
      car == "Hennessey Venom GT"              ~ "Hennessey Venom GT",
      car == "Bugatti Veyron 16.4 Super Sport" ~ "Bugatti Veyron SS",
      car == "Rimac C Two"                     ~ "Rimac C Two"
    ),
    car_short = case_when(
      car == "Hennessey Venom F5"              ~ "Venom F5",
      car == "Bugatti Chiron Super Sport 300+" ~ "Chiron SS 300+",
      car == "SSC Tuatara"                     ~ "Tuatara",
      car == "Koenigsegg Jesko"                ~ "Jesko",
      car == "Koenigsegg Agera RS"             ~ "Agera RS",
      car == "Hennessey Venom GT"              ~ "Venom GT",
      car == "Bugatti Veyron 16.4 Super Sport" ~ "Veyron SS",
      car == "Rimac C Two"                     ~ "C Two"
    )
  )
```

#### [5. Visualization Parameters]{.smallcaps}

```{r}
#| label: params
#| include: true
#| warning: false

### |- Colors ----
colors <- get_theme_colors(
  palette = list(
    burgundy      = "#6D1A36",
    steel         = "#4A6FA5",
    neutral_dark  = "#2B2B2B",
    neutral_mid   = "#6B6B6B",
    neutral_light = "#E5E5E5",
    grid_light    = "#D9D9D9",
    empty_tile    = "#F0F0F0"
  )
)

### |- Titles and caption ----
title_text <- "The World's Fastest Cars: Some Sell Engineering, Others Sell Exclusivity"

subtitle_text <- glue(
  "Top: deviation from the median in <b>cost per horsepower</b> and ",
  "<b>speed delivered per horsepower</b>. ",
  "<span style='color:{colors$palette$burgundy}'>Burgundy</span> = worse value; ",
  "<span style='color:{colors$palette$steel}'>steel blue</span> = better value.<br>",
  "Bottom: the same cars by <b>units produced</b>. Each filled square = one car built."
)

caption_text <- create_mm_caption(
  mm_year     = 2026,
  mm_week     = 11,
  source_text = "RankRed.com · data.world/makeovermonday"
)

### |- fonts ----
setup_fonts()
fonts <- get_font_families()

### |- plot theme ----
base_theme <- create_base_theme(colors)

weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    panel.grid.major.x = element_line(color = colors$palette$grid_light, linewidth = 0.3),
    panel.grid.major.y = element_blank(),
    axis.ticks         = element_blank(),
    axis.text.x        = element_text(size = 9, color = colors$palette$neutral_mid),
    axis.text.y        = element_text(size = 10, color = colors$palette$neutral_mid),
    axis.title         = element_blank(),
    plot.title = element_text(
      size = rel(1.25), family = fonts$title, face = "bold",
      color = colors$palette$neutral_dark, lineheight = 1.05,
      margin = margin(t = 3, b = 4)
    ),
    plot.subtitle = element_text(
      size = rel(0.8), family = fonts$subtitle,
      color = colors$palette$neutral_mid, lineheight = 1.1,
      margin = margin(t = 0, b = 8)
    )
  )
)

theme_set(weekly_theme)
```

#### [6. Plot]{.smallcaps}

```{r}
#| label: plot
#| warning: false

### |- PANEL A: Diverging Bars — Luxury Premium vs. Engineering Efficiency ----

# Derived Data ----
med_price_hp <- median(df$price_per_hp)
med_speed_hp <- median(df$speed_per_hp)

plot_df <- df |>
  mutate(
    price_hp_dev = price_per_hp - med_price_hp,
    speed_hp_dev = speed_per_hp - med_speed_hp,
    cost_flag    = if_else(price_hp_dev > 0, "Above median cost", "Below median cost"),
    eff_flag     = if_else(speed_hp_dev > 0, "Above median efficiency", "Below median efficiency")
  ) |>
  arrange(desc(price_hp_dev)) |>
  mutate(car_order = factor(car_short, levels = rev(car_short)))

### |-  left panel: cost per HP ----
p_cost <- plot_df |>
  ggplot(aes(x = price_hp_dev, y = car_order, fill = cost_flag)) +
  geom_col(width = 0.62) +
  geom_vline(xintercept = 0, linewidth = 0.6, color = colors$palette$neutral_dark) +
  geom_text(
    aes(
      label = if_else(price_hp_dev > 0,
                      paste0("+", dollar(round(price_hp_dev))),
                      dollar(round(price_hp_dev))),
      x = if_else(price_hp_dev > 0, price_hp_dev + 28, price_hp_dev - 28)
    ),
    size = 3,
    color = colors$palette$neutral_dark,
    fontface = "bold",
    hjust = if_else(plot_df$price_hp_dev > 0, 0, 1)
  ) +
  annotate(
    "segment",
    x = 0, xend = 0, y = 0.55, yend = 1.15,
    color = colors$palette$neutral_mid, linewidth = 0.35, linetype = 2
  ) +
  annotate(
    "text",
    x = 20, y = 0.95,
    label = glue("median = {dollar(round(med_price_hp))}/HP"),
    hjust = 0, size = 2.7,
    color = colors$palette$neutral_mid, fontface = "italic"
  ) +
  scale_fill_manual(
    values = c(
      "Above median cost" = colors$palette$burgundy,
      "Below median cost" = colors$palette$steel
    ),
    guide = "none"
  ) +
  scale_x_continuous(
    labels = label_dollar(),
    limits = c(-520, 1325),
    expand = expansion(mult = c(0, 0))
  ) +
  labs(
    title    = "Cost per horsepower",
    subtitle = "Deviation from median ($/HP) · sorted most to least expensive"
  ) +
  theme(
    plot.title    = element_text(size = rel(1.0), face = "bold"),
    plot.subtitle = element_text(size = rel(0.76), margin = margin(b = 8)),
    axis.text.y   = element_text(color = colors$palette$neutral_mid)
  )

### |-  right panel: speed per HP ----
p_speed <- plot_df |>
  ggplot(aes(x = speed_hp_dev, y = car_order, fill = eff_flag)) +
  geom_col(width = 0.62) +
  geom_vline(xintercept = 0, linewidth = 0.6, color = colors$palette$neutral_dark) +
  geom_text(
    aes(
      label = if_else(speed_hp_dev > 0,
                      paste0("+", number(speed_hp_dev, accuracy = 0.001)),
                      number(speed_hp_dev, accuracy = 0.001)),
      x = if_else(speed_hp_dev > 0, speed_hp_dev + 0.004, speed_hp_dev - 0.004)
    ),
    size = 3,
    color = colors$palette$neutral_dark,
    fontface = "bold",
    hjust = if_else(plot_df$speed_hp_dev > 0, 0, 1)
  ) +
  annotate(
    "segment",
    x = 0, xend = 0, y = 0.55, yend = 1.15,
    color = colors$palette$neutral_mid, linewidth = 0.35, linetype = 2
  ) +
  annotate(
    "text",
    x = 0.002, y = 0.95,
    label = glue("median = {number(med_speed_hp, accuracy = 0.001)} km/h/HP"),
    hjust = 0, size = 2.7,
    color = colors$palette$neutral_mid, fontface = "italic"
  ) +
  scale_fill_manual(
    values = c(
      "Above median efficiency" = colors$palette$steel,
      "Below median efficiency" = colors$palette$burgundy
    ),
    guide = "none"
  ) +
  scale_x_continuous(
    labels = label_number(accuracy = 0.01),
    limits = c(-0.10, 0.07),
    expand = expansion(mult = c(0, 0))
  ) +
  labs(
    title    = "Speed per horsepower",
    subtitle = "Deviation from median (km/h per HP) · same car order as left panel"
  ) +
  theme(
    plot.title    = element_text(size = rel(1.0), face = "bold"),
    plot.subtitle = element_text(size = rel(0.76), margin = margin(b = 8)),
    axis.text.y   = element_blank()
  )

### |- PANEL B: Unit Chart — How Many Were Ever Built? ----

# Derived Data ----
rarity_base <- df |>
  transmute(
    car_short,
    units,
    facet_label = glue("{car_short}\n{units} units")
  ) |>
  arrange(desc(units)) |>
  mutate(facet_label = factor(facet_label, levels = facet_label))

max_units <- max(rarity_base$units)
n_cols    <- 15
n_rows    <- ceiling(max_units / n_cols)

rarity_full <- rarity_base |>
  rowwise() |>
  reframe(
    car_short   = car_short,
    facet_label = facet_label,
    units       = units,
    unit_id     = seq_len(n_cols * n_rows)
  ) |>
  mutate(
    filled = unit_id <= units,
    col    = (unit_id - 1) %% n_cols + 1,
    row    = (unit_id - 1) %/% n_cols + 1
  )

### |-  unit chart ----
p_rarity <- rarity_full |>
  ggplot(aes(x = col, y = -row, fill = filled)) +
  geom_tile(width = 0.8, height = 0.8, color = "white", linewidth = 0.45) +
  facet_wrap(~facet_label, ncol = 4) +
  scale_fill_manual(
    values = c("TRUE" = "#4A4A4A", "FALSE" = "#E8E8E8"),
    guide  = "none"   # filled vs. empty is self-evident; no legend needed
  ) +
  labs(
    title    = "How many were ever built?",
    subtitle = "Each square represents one car. Common empty grid makes rarity comparable across models."
  ) +
  coord_equal() +
  theme(
    axis.text.x        = element_blank(),
    axis.text.y        = element_blank(),
    axis.line          = element_blank(),
    panel.grid         = element_blank(),
    panel.grid.major   = element_blank(),
    panel.grid.minor   = element_blank(),
    panel.grid.major.x = element_blank(),
    strip.text = element_text(
      size = rel(0.8), face = "bold",
      color = colors$palette$neutral_dark,
      lineheight = 1.3
    ),
    panel.spacing   = unit(1.1, "lines"),
    legend.position = "none"
  )

### |-  Combined Plots ----
p_top <- p_cost + p_speed + plot_layout(widths = c(1.15, 1))

combined_plots <- p_top / p_rarity +
  plot_layout(heights = c(1.05, 1)) +
  plot_annotation(
    title    = title_text,
    subtitle = subtitle_text,
    caption  = caption_text,
    theme = theme(
      plot.title = element_text(
        size = rel(1.42), face = "bold",
        color = colors$palette$neutral_dark,
        margin = margin(b = 5)
      ),
      plot.subtitle = element_markdown(
        size = rel(0.88),
        color = colors$palette$neutral_mid,
        lineheight = 1.15,
        margin = margin(b = 12)
      ),
      plot.caption = element_markdown(
        size = rel(0.70),
        color = colors$palette$neutral_mid,
        hjust = 0
      ),
      plot.margin = margin(t = 14, r = 16, b = 12, l = 16)
    )
  )

```

#### [7. Save]{.smallcaps}

```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plots, 
  type = "makeovermonday", 
  year = current_year,
  week = current_week,
  width = 14, 
  height = 11
  )
```

#### [8. Session Info]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for Session Info

```{r, echo = FALSE}
#| eval: true
#| warning: false

sessionInfo()
```
:::

#### [9. GitHub Repository]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo

The complete code for this analysis is available in `r create_link(project_file, repo_file)`.

For the full repository, `r create_link("click here", repo_main)`.
:::

#### [10. References]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for References

**Primary Data (Makeover Monday):** 1. Makeover Monday `r current_year` Week `r current_week`: `r create_link("8 Fastest Cars in the World (2026)", data_main)` 2. Original Article: `r create_link("Fastest Cars in the World", "https://www.rankred.com/fastest-cars-in-the-world/")` - Source: RankRed - Coverage: Top 8 fastest production cars as of 2026, including speed, power, price, and production figures

**Source Data:** 3. Dataset: `r create_link("2026 Week 11 — 8 Fastest Cars in the World", "https://data.world/makeovermonday/8-fastest-cars-in-the-world-as-of-2026")` - Source: RankRed via data.world/makeovermonday - Data includes: Car name, manufacturer, country, engine type, top speed (mph and km/h), horsepower, torque, 0–100 km/h time, price (USD), units produced, price per HP, and speed per HP - Scope: 8 production cars ranked by verified top speed as of 2026

**Note:** All values are reported directly from the source. Deviation from median was computed for price per HP and speed per HP to enable the diverging bar comparison. No external data sources, price deflators, or population adjustments were applied.
:::

#### [11. Custom Functions Documentation]{.smallcaps}

::: {.callout-note collapse="true"}
##### 📦 Custom Helper Functions

This analysis uses custom functions from my personal module library for efficiency and consistency across projects.

**Functions Used:**

-   **`fonts.R`**: `setup_fonts()`, `get_font_families()` - Font management with showtext
-   **`social_icons.R`**: `create_social_caption()` - Generates formatted social media captions
-   **`image_utils.R`**: `save_plot()` - Consistent plot saving with naming conventions
-   **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()` - Custom ggplot2 themes

**Why custom functions?**\
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.

**Source Code:**\
View all custom functions → [GitHub: R/utils](https://github.com/poncest/personal-website/tree/master/R)
:::

© 2024 Steven Ponce

Source Issues