if (!require(tidyverse)) {
install.packages("tidyverse")
library(tidyverse)
}
if (!require(patchwork)) {
install.packages("patchwork")
library(patchwork)
}
if (!require(ggrepel)) {
install.packages("ggrepel")
library(ggrepel)
}
# Read data
historic_station_met <- readr::read_csv(
'https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-10-21/historic_station_met.csv'
)
station_meta <- readr::read_csv(
'https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-10-21/station_meta.csv'
)
welsh_stations <- c("aberporth", "cardiff", "cwmystwyth", "valley")
welsh_data <- historic_station_met |>
filter(station %in% welsh_stations)
welsh_data_2024 <- welsh_data %>%
mutate(month = month.name[as.integer(month)]) %>%
filter(year == 2024) |>
mutate(month = factor(month, levels = month.name))
mean_sunshine <- welsh_data_2024 |>
group_by(month) |>
summarise(mean_sunshine = mean(sun, na.rm = T)) |>
mutate(angle = (as.numeric(month) - 0.5) / 12 * 360)
mean_rain <- welsh_data_2024 |>
group_by(month) |>
summarise(mean_rain = mean(rain, na.rm = T)) |>
mutate(angle = (as.numeric(month) - 0.5) / 12 * 360)
mean_max_temp <- welsh_data_2024 |>
group_by(month) |>
summarise(mean_max_temp = mean(tmax, na.rm = T))
mean_min_temp <- welsh_data_2024 |>
group_by(month) |>
summarise(mean_min_temp = mean(tmin, na.rm = T))
##### Graphs
max_r <- max(mean_sunshine$mean_sunshine) + 5
sunshine <- ggplot(
mean_sunshine,
aes(x = month, y = mean_sunshine, fill = mean_sunshine)
) +
geom_bar(stat = "identity", width = 1, color = "gold") +
geom_label_repel(
aes(
label = paste0(round(mean_sunshine, 1), " hrs"),
y = mean_sunshine + 30
),
size = 3.5,
color = "black"
) +
coord_polar(start = 0) + # makes it circular
annotate("point", x = 0, y = 0, size = 15, color = "gold") + # sun core
scale_fill_gradient(low = "yellow", high = "orange") +
theme_minimal() +
theme(
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank(),
legend.position = "bottom",
axis.text.x = element_text(size = 12, face = "bold"),
title = element_text(size = 12, face = "bold")
) +
labs(
fill = "Mean Sunshine (hrs)",
title = "Average Monthly Hours of Sunshine in Wales in 2024"
)
#######################=== Rain
rain <- ggplot(mean_rain, aes(x = month, y = mean_rain, fill = mean_rain)) +
geom_bar(stat = "identity", width = 1, color = "lightgrey") +
geom_label_repel(
aes(
label = paste0(round(mean_rain, 1), " mm"),
y = mean_rain + 30
),
size = 5,
color = "white"
) +
coord_polar(start = 0) + # makes it circular
# annotate("point", x = 0, y = 0, size = 15, color = "#2E5984") + # sun core
scale_fill_gradient(low = "#BCD2E8", high = "#1C6CCC") +
theme_minimal() +
theme(
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank(),
legend.position = "bottom",
axis.text.x = element_text(size = 12, face = "bold"),
title = element_text(size = 12, face = "bold")
) +
labs(
fill = "Average Monthly Rainfall (mm)",
title = "Average Monthly Rainfall in Wales in 2024"
)
######## = Average Max Temperature
maxtemp <- ggplot(
mean_max_temp,
aes(x = month, y = mean_max_temp, fill = mean_max_temp)
) +
geom_bar(stat = "identity", width = 1, color = "lightgrey") +
geom_label_repel(
aes(
label = paste0(round(mean_max_temp, 1), " °C"),
y = mean_max_temp + 5
),
size = 5,
color = "black"
) +
coord_polar(start = 0) + # makes it circular
# annotate("point", x = 0, y = 0, size = 15, color = "#2E5984") + # sun core
scale_fill_gradient(low = "#c4d7ff", high = "#ff3800") +
theme_minimal() +
theme(
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank(),
legend.position = "bottom",
axis.text.x = element_text(size = 12, face = "bold"),
title = element_text(size = 12, face = "bold")
) +
labs(
fill = "Average Maximum Temperature (°C)",
title = "Average Maximum Monthly Temperature in Wales in 2024"
)
######## = Average min Temperature
mintemp <- ggplot(
mean_min_temp,
aes(x = month, y = mean_min_temp, fill = mean_min_temp)
) +
geom_bar(stat = "identity", width = 1, color = "lightgrey") +
geom_label_repel(
aes(
label = paste0(round(mean_min_temp, 1), " °C"),
y = mean_min_temp + 5
),
size = 5,
color = "black"
) +
coord_polar(start = 0) + # makes it circular
# annotate("point", x = 0, y = 0, size = 15, color = "#2E5984") + # sun core
scale_fill_gradient(low = "#c4d7ff", high = "#eeea04ff") +
theme_minimal() +
theme(
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid = element_blank(),
legend.position = "bottom",
axis.text.x = element_text(size = 12, face = "bold"),
title = element_text(size = 12, face = "bold")
) +
labs(
fill = "Average Minimum Temperature (°C)",
title = "Average Minimum Monthly Temperature in Wales in 2024"
)
plots <- (sunshine + rain)
plots2 <- (mintemp + maxtemp)