Lab 06 - Packages and Report Generation

Author

Magnus Tveit

Introduction

This report uses the GISS global temperature anomaly dataset to demonstrate basic data loading, summary statistics, and plotting in R using Quarto.

Loading the Data

giss <- read.csv("./data/giss_temp.csv")
summary(giss)
      Year          Month          DecDate        TempAnom        
 Min.   :1881   Min.   : 1.00   Min.   :1881   Min.   :-0.860000  
 1st Qu.:1913   1st Qu.: 3.75   1st Qu.:1914   1st Qu.:-0.210000  
 Median :1946   Median : 6.50   Median :1946   Median :-0.050000  
 Mean   :1946   Mean   : 6.50   Mean   :1946   Mean   :-0.009427  
 3rd Qu.:1979   3rd Qu.: 9.25   3rd Qu.:1979   3rd Qu.: 0.150000  
 Max.   :2011   Max.   :12.00   Max.   :2012   Max.   : 0.880000  

The dataset contains monthly temperature anomalies from 1881 to 2012. The TempAnom column gives the deviation from the long-term mean (1961-1990).

Annual Mean Temperature Anomaly

Here we calculate the mean temperature anomaly for each year, and create a corresponding vector of years.

annualTemp <- tapply(giss$TempAnom, giss$Year, mean)
years <- unique(giss$Year)

Distribution of Temperature Anomalies

The histogram below shows the distribution of all monthly temperature anomaly values across the full record.

hist(giss$TempAnom, breaks = 20,
     xlab = "Temperature Anomaly", main = "Distribution of Temperature Anomalies",
     col = "steelblue")

The distribution is roughly centered near zero, with a slight positive skew reflecting the warming trend in recent decades.

Annual Temperature Anomaly Over Time

The line plot below shows the annual mean temperature anomaly from 1881 to 2012. The dashed horizontal line marks zero, the long-term reference average.

plot(years, annualTemp, type = 'l', lwd = 2, col = "darkorange",
     xlab = "Year", ylab = "Temperature Anomaly",
     main = "Annual Mean Temperature Anomaly")
abline(h = 0, lty = 2)

The plot clearly shows the well-known warming trend, with anomalies becoming consistently positive from the 1980s onward.