library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Read Meteorological Data from Russian Arctic Sojna Weather
Station
setwd("~/Desktop/GTECH 38520/Project")
Sojna<-read_fwf(file.path("Meteorology_Files","uni.sojna.22271.dat"))
## Rows: 480 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
##
## chr (1): X22
## dbl (21): X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, ...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
colnames(Sojna)[1:9] <- c("station", "year", "month", "day", "time","position", "latitude", "longitude", "temperature")
Sojna_clean<- Sojna %>%
select(year, month, temperature)
Sojna_clean <- Sojna_clean %>%
mutate(temperature = na_if(temperature, 999.9))
Table for Monthly Mean and Monthly Median Air Temperature
entire_monthly_stats <- Sojna_clean %>%
group_by(month) %>%
summarise(mean_temp = mean(temperature, na.rm = TRUE), median_temp = median(temperature, na.rm = TRUE))
entire_monthly_stats
## # A tibble: 12 × 3
## month mean_temp median_temp
## <dbl> <dbl> <dbl>
## 1 1 -12.4 -11.4
## 2 2 -12.8 -12.4
## 3 3 -9.45 -9.35
## 4 4 -5.77 -5.65
## 5 5 -0.287 -0.3
## 6 6 5.98 6.35
## 7 7 10.9 11
## 8 8 9.70 9.7
## 9 9 6.36 6.3
## 10 10 1.15 1.2
## 11 11 -4.36 -4.25
## 12 12 -8.36 -7.6
early_stats <- Sojna_clean %>%
filter(year >= 1961 & year <= 1980) %>%
group_by(month) %>%
summarise(mean_early = mean(temperature, na.rm = TRUE), median_early = median(temperature, na.rm = TRUE))
early_stats
## # A tibble: 12 × 3
## month mean_early median_early
## <dbl> <dbl> <dbl>
## 1 1 -12.3 -11.4
## 2 2 -13.5 -12.8
## 3 3 -10.1 -9.85
## 4 4 -5.86 -6.05
## 5 5 -0.355 -0.65
## 6 6 5.52 6.15
## 7 7 10.9 11
## 8 8 9.89 10
## 9 9 6.40 6.2
## 10 10 0.97 1
## 11 11 -4.40 -3.9
## 12 12 -8.26 -7.6
late_stats <- Sojna_clean %>%
filter(year >= 1981 & year <= 2000) %>%
group_by(month) %>%
summarise(mean_late = mean(temperature, na.rm = TRUE), median_late = median(temperature, na.rm = TRUE))
late_stats
## # A tibble: 12 × 3
## month mean_late median_late
## <dbl> <dbl> <dbl>
## 1 1 -12.5 -11.6
## 2 2 -12.1 -11.6
## 3 3 -8.84 -8.5
## 4 4 -5.68 -5.35
## 5 5 -0.22 -0.05
## 6 6 6.44 6.55
## 7 7 10.8 10.9
## 8 8 9.5 9.55
## 9 9 6.31 6.45
## 10 10 1.32 1.25
## 11 11 -4.32 -4.55
## 12 12 -8.44 -7.6
final_table <- entire_monthly_stats %>%
left_join(early_stats, by = "month") %>%
left_join(late_stats, by = "month")
final_table
## # A tibble: 12 × 7
## month mean_temp median_temp mean_early median_early mean_late median_late
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 -12.4 -11.4 -12.3 -11.4 -12.5 -11.6
## 2 2 -12.8 -12.4 -13.5 -12.8 -12.1 -11.6
## 3 3 -9.45 -9.35 -10.1 -9.85 -8.84 -8.5
## 4 4 -5.77 -5.65 -5.86 -6.05 -5.68 -5.35
## 5 5 -0.287 -0.3 -0.355 -0.65 -0.22 -0.05
## 6 6 5.98 6.35 5.52 6.15 6.44 6.55
## 7 7 10.9 11 10.9 11 10.8 10.9
## 8 8 9.70 9.7 9.89 10 9.5 9.55
## 9 9 6.36 6.3 6.40 6.2 6.31 6.45
## 10 10 1.15 1.2 0.97 1 1.32 1.25
## 11 11 -4.36 -4.25 -4.40 -3.9 -4.32 -4.55
## 12 12 -8.36 -7.6 -8.26 -7.6 -8.44 -7.6
Plot for Monthly Mean Stats with Standard Deviation
monthly_stats_all <- Sojna_clean %>%
group_by(month) %>%
summarise(mean_temp = mean(temperature, na.rm = TRUE),
sd_temp = sd(temperature, na.rm = TRUE)) %>%
bind_rows(Sojna_clean %>%
summarise(month = 13,
mean_temp = mean(temperature, na.rm = TRUE),
sd_temp = sd(temperature, na.rm = TRUE)))
ggplot(monthly_stats_all, aes(
x = factor(month, levels = 1:13,labels = c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Annual")),
y = mean_temp)) +
geom_col(fill = "lightgreen") +
geom_errorbar(aes(ymin = mean_temp - sd_temp,
ymax = mean_temp + sd_temp),width = 0.2) +
labs(title = "Monthly Mean Air Temperature at Sojna Weather Station in the Russian Arctic", x = "Month", y = "Air Temperature (°C)")

Plot Comparison for Earlier Period (1961-1980) vs Later Period
(1981-2000)
comparison <- early_stats %>%
left_join(late_stats, by = "month")
comparison_long <- comparison %>%
pivot_longer(cols = c(mean_early, mean_late),names_to = "period",values_to = "mean_temp")
ggplot(comparison_long, aes(
x = factor(month,
levels = 1:12,
labels = c("Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec")),
y = mean_temp,fill = period)) +
geom_col(position = "dodge") +
scale_fill_manual(
values = c("mean_early" = "blue", "mean_late" = "red"),
labels = c("1961–1980", "1981–2000")) +
labs(title = "Early vs Late Period Monthly Mean Temperatures at Sojna Weather Station",
x = "Month",y = "Air Temperature (°C)",fill = "Time Period")
