This project examines global surface temperature data published by Our World in Data. The dataset provides annual average surface temperatures for countries and regions over time, allowing temperature patterns to be compared across locations and years.
The data and accompanying information are available from Our World in Data: https://ourworldindata.org/grapher/average-annual-surface-temperature
I selected this dataset because climate and temperature data have important geographic and environmental applications. As someone with a background in Geomatics Engineering and GIS who is now studying Data Science, I am interested in how geographic data can be transformed and analyzed using R.
The original dataset is loaded directly from Our World in Data. Using a web-based CSV file instead of a file stored on my computer makes the analysis reproducible for other users.
temperature_raw <- read.csv(
"https://ourworldindata.org/grapher/average-annual-surface-temperature.csv"
)
head(temperature_raw)
## Entity Code Year Average.surface.temperature
## 1 Afghanistan AFG 1940 11.32770
## 2 Afghanistan AFG 1941 13.32476
## 3 Afghanistan AFG 1942 12.88545
## 4 Afghanistan AFG 1943 11.52477
## 5 Afghanistan AFG 1944 12.14367
## 6 Afghanistan AFG 1945 11.36659
For the final data frame, I selected the country or region name, country code, year, and average surface temperature. I renamed the columns to make them easier to understand and to clearly indicate that temperature is measured in degrees Celsius.
temperature_clean <- temperature_raw[, c(
"Entity",
"Code",
"Year",
"Average.surface.temperature"
)]
names(temperature_clean) <- c(
"country_or_region",
"country_code",
"year",
"temperature_celsius"
)
head(temperature_clean)
## country_or_region country_code year temperature_celsius
## 1 Afghanistan AFG 1940 11.32770
## 2 Afghanistan AFG 1941 13.32476
## 3 Afghanistan AFG 1942 12.88545
## 4 Afghanistan AFG 1943 11.52477
## 5 Afghanistan AFG 1944 12.14367
## 6 Afghanistan AFG 1945 11.36659
The final data frame contains four clearly labeled variables: country
or region, country code, year, and average surface temperature in
degrees Celsius. The temperature_celsius variable is the
main outcome of interest, while the other variables provide geographic
and temporal information that can be used to compare temperature
patterns.
str(temperature_clean)
## 'data.frame': 18318 obs. of 4 variables:
## $ country_or_region : chr "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
## $ country_code : chr "AFG" "AFG" "AFG" "AFG" ...
## $ year : int 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 ...
## $ temperature_celsius: num 11.3 13.3 12.9 11.5 12.1 ...
summary(temperature_clean)
## country_or_region country_code year temperature_celsius
## Length :18318 Length :18318 Min. :1940 Min. :-36.60
## N.unique : 213 N.unique : 196 1st Qu.:1961 1st Qu.: 10.24
## N.blank : 0 N.blank : 1548 Median :1982 Median : 21.26
## Min.nchar: 4 Min.nchar: 0 Mean :1982 Mean : 17.46
## Max.nchar: 48 Max.nchar: 8 3rd Qu.:2004 3rd Qu.: 25.01
## Max. :2025 Max. : 29.79
This assignment demonstrates how publicly available temperature data can be loaded directly from the web into R and transformed into a data frame with meaningful column names. The resulting data frame is reproducible and provides a simple structure for analyzing changes in surface temperature across countries and years.
To extend this work, I would compare temperature trends among different countries and investigate how average surface temperatures have changed over time. I would also consider creating maps and other visualizations to examine geographic patterns and verify the results using additional climate data sources.