Tidy Tuesday 1

Code
library(tidyverse)
cia_factbook <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-10-22/cia_factbook.csv')
cia_factbook |>
select(country, area) |>
arrange(desc(area)) |> slice_max(area, n = 10)
plot_area <- cia_factbook |>
mutate(area_million_km2 = area / 1e6) |>
slice_max(area_million_km2, n = 10) |>
ggplot() +
aes(x = area_million_km2, y = reorder(country, area_million_km2)) +
geom_bar(stat = "identity", fill = "steelblue") +
scale_x_continuous(position = "top", labels = scales::label_number(scale = 1, suffix = "M")) +
labs(alt = "",
title="Top 10 countries by geographical size",
subtitle = "Total land area (in million kmĀ²) ",
caption = "Source: CIA Factbook | Code: Joe Chelladurai",
x = NULL, y = NULL) +
theme_minimal() +
theme(text = element_text(family = "PT Sans"),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill = "white"),
plot.title.position = "plot",
plot.caption.position = "plot",
plot.title = element_text(face = "bold", size = 12),
plot.subtitle = element_text(face = "italic", size = 10),
axis.text = element_text(size = 9))
ggsave("tidy_tuesday_oct_25.png", plot_area, width = 3, height = 3)
alt_text = "A bar chart displaying the top ten countries by geographical size, with the following areas in millions of square kilometers: Russia (17.1), Canada (9.9), United States (9.8), China (9.6), Brazil (8.5), Australia (7.7), India (3.3), Argentina (2.8), Kazakhstan (2.7), and Algeria (2.4)."