This lab is in two parts: * PartI focuses on modern global temperature and atmospheric CO2 * PartII focuses on the Ice Core record with geologic history of temperature and CO2. PartII also includes the modern $$13C atmospheric record for additional evidence of anthropogenic climate change.
knitr::opts_chunk$set(echo= TRUE, eval= TRUE)
Read the Lab2 Description to answer these questions:
library(dplyr)
library(ggplot2)
library(readxl) # use install.packages("readxl") or install manually in Packages tab
The first step for opening data in R is to tell R which folder on your computer contains the data. The folder that R reads is called 'the working directory' or wd. You can use the command getwd()
to find out which folder R is currently looking at.
It will be easiest if you save the data and your .Rmd in the same folder because the default wd is the directory that your R script file comes from. If the data and .Rmd are in the same place, you won't need to change anything.
Confirm that your wd is the folder where your data is saved:
OK, ready to import data.
Read the data from the excel sheet by specifying which sheet and which line the data starts on.
We're going to load all the data for the entire assignment in this step. I like to set-up my code this way, so that I can see all the data I plan to use by looking at the beginning of my R script. Each dataframe that we create should show up in your environment.
setwd("/Users/memauritz/Desktop/R/R_programs/Teaching/EcosystemEcology_UTEP/Lab2_Data")
modern.temp <- read_excel("Lab2_AllData.xlsx", sheet="GlobalTemperatureData_1880_2014", skip=2)
modern.temp.anomaly <- read_excel("Lab2_AllData.xlsx", sheet="GlobalTempAnomaly_1880_2019", skip=1)
modern.co2 <- read_excel("Lab2_AllData.xlsx", sheet="MaunaLoa_AnnualMean_CO2", skip=56)
Use %>% glimpse
to see the column names and the column type.
All of our data is numeric so all the column types should be < dbl >.
You can also check this in the excel file to see how R reads data.
Modern Temperature data set:
## Rows: 135
## Columns: 2
## $ Year <dbl> 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1…
## $ Temperature_F <dbl> 56.822, 56.966, 56.912, 56.858, 56.714, 56.750, 56.768,…
Modern Temperature anomaly data set:
## Rows: 140
## Columns: 3
## $ Year <dbl> 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 18…
## $ Temp_anom_C <dbl> -0.16, -0.07, -0.10, -0.16, -0.28, -0.32, -0.30, -…
## $ Temp_anom_C_smooth <dbl> -0.08, -0.12, -0.16, -0.19, -0.23, -0.25, -0.26, -…
Modern CO2 concentration data set:
## Rows: 61
## Columns: 3
## $ Year <dbl> 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967,…
## $ Mean_co2 <dbl> 315.97, 316.91, 317.64, 318.45, 318.99, 319.62, 320.0…
## $ Uncertainty_co2 <dbl> 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12,…
When trying to remember the names of columns to graph or analyse your data, you can use colnames(data)
anytime for a quick reminder of what's in a data frame. Eg:
colnames(modern.temp)
## [1] "Year" "Temperature_F"
Determine current rates of air temperature and CO2 change from modern datasets
mutate()
and the F to C conversion to calculate Celsius. We'll use Celsius because it is a scientific unit:\(Temperature(C) = (Temperature(F) - 32) * \frac{5}{9}\)
geom_point()
and geom_line()
:The rate of change is represented by the slope of a linear line fit. Recall the equation of a linear line:
\(y = mx + b\)
Where y is the data on the y-axis, x is the data on the x-axis, m is the slope of the relationship, and b describes the intercept. Remember, the intercept will be in the units of the y-variable and the slope will be in units y/units x (ie: Celsius/year).
The R function that fits a straight line is lm(y ~ x, data)
Answer the following:
a. What is the equation of the line? b. What is the rate of temperature change (with units)? (hint: don't forget time in the units)
Fit a linear line to the temperature change over year 1880 to 2014:
Display the result of the linear fit to find the value of the slope. One way to do this is by simply calling the object you just created with the line fit:
The output will show you the formula that was used to predict the line, and it will tell you the (Intercept) and slope. In R the slope is always given the name of the x-variable, in this case Year.
Answer the following:
a. Based on the equation, and the figure, what would you conclude about global temperature change since 1880?
Plot the rate of change with the information from the lm() output (you can round to 3 significant figures) and add + geom_abline(intercept = , slope= )
to your ggplot.
R can also do simple math, eg:
1+2
## [1] 3
And:
2*7
## [1] 14
The warming trend we see today is considered to have accelerated from the mid 1900's when the globalisation we recognise today started to grow. Calculate a new temperature trend-line that starts in 1950. You can do this by using filter to create a new dataset that starts in 1950, and fit a line.
Answer the following:
a. What is the equation of the line?
What is the rate of temperature change since 1950 (with units)? (hint: don't forget time in the units)
Compare the rate of change between 1880-2014 and 1950-2014.
Do you have any concerns about the approach of graphing a straight line fit to the data from 1880-2014?
Calculating rate of change since 1950:
NASA GISS uses a baseline period from 1951-1980.
Do the following:
a. graph the column Temp_anom_C in modern.temp.anomaly
add accurate titles and axis labels
add +geom_hline(yintercept=0, colour="grey")
as a 0 reference to make it easier to distinguish negative and positive anomalies.
add +geom_segment(aes(x=1951, xend=1980, y=0, yend=0), colour="red")
to show the baseline period in your plot.
Answer the following:
e. How many degrees did the temperature change from the baseline year to 2019?
Graph of modern temperature anomalies:
Explore whether modern temperature and CO2 concentrations are related
The data is in modern.co2, and we will use the Mean_co2 column which is the average annual atmospheric CO2 concentration in ppm.
Answer/do the following:
a. Graph the change in modern CO2 concentrations measured at Mauna Loa from 1950-2019
What is the equation of the line?
What is the rate of CO2 change since 1950 (with units)? (hint: don't forget time in the units)
Calculate the rate of change:
To do this, merge the temperature anomaly with the modern co2 data by Year. You can use the merge()
or dplyr inner_join()
functions.
Answer the following:
a. What is the relationship between atmospheric CO2 and the global temperature anomaly?
Based on this relationship, what was the atmospheric CO2 concentration threshold when temperatures began to increase? Explain your answer.
What would you conclude about the relationship between global mean temperature and atmospheric CO2?