This lab is in two parts:
knitr::opts_chunk$set(echo= TRUE, eval= TRUE)
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.c13 <- read_excel("Lab2_AllData.xlsx", sheet="MaunaLoa_Monthly_C13", skip=54, na=c("-99.99"))
vostok.temp <- read_excel("Lab2_AllData.xlsx", sheet="Vostok_Temp", skip=1, na=c("-99.99"))
vostok.co2 <- read_excel("Lab2_AllData.xlsx", sheet="Vostok_CO2", skip=1, na=c("-99.99"))
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 \(\delta\) 13C signature data set
Vostok Ice Core Temperature data set
Vostok Ice Core CO2 concentration data set
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.c13)
## [1] "Year" "Month"
## [3] "Date...3" "Date...4"
## [5] "C13_permil" "C13_permil_seas_adj"
## [7] "C13_fit_permil" "C13_fit_permil_seas_adj"
## [9] "C13_filled_permil" "C13_smooth"
Compare current and pre-historical temperature and CO2 concentrations using data from the Vostok ice core
There are three variables that you will analyse from the ice cores. You will graph temperature anomalies and absolute temperatures to compare with the modern records. You will also analyze pre-historic atmospheric CO2 concentration, which has been measured from air bubbles trapped in the ice. We can use these data to see what temperatures and CO2 concentrations were like 400 000 years into the past, during which human activity has been minimal.
Use vostok.temp dataframe and the column Temp_anom_C_vost
Do the following:
the years are in Years_BP (that's years before present) and go back to 420 000 BP. Divide the years by 1000 in the x-axis so that the unit becomes kyr BP
add Temp_anom_C_vost with both a point and a line geom
add a zero line for reference, like you did for the modern temperature anomaly
add a blue dashed vertical line and label for the start of the Holocene 11 kyr ago using: + geom_vline(xintercept=11, colour="blue", linetype="dashed")
+ geom_label(label="Holocene start",x=17,y=5)
specify the range of the y-axis + ylim(xmin=-10, ymax=5)
add meaningful titles and axis labels
Graph Vostok temperature anomalies:
[Graph Here]
Do the following:
geom_label(label="", x=17, y=300)
Graph Vostok CO2 concentrations:
[Graph Here]
Answer the following:
What are the maximum pre-historic CO2 concentrations during the periods with large positive temperature anomalies (~400 kyr BP, 300 kyr BP, 200 kyr BP, 100 kyr BP)?
Describe how CO2 fluctuations compare to the temperature anomaly fluctuations in the Ice Core data? Think generally about patterns, for example timing of peaks and troughs in the graphs. You could re-print the both the temperature anomaly graph and the co2 graph in the same chunk and R will let you flip between the two. It might be easier to compare.
The Earth started to emerge from the last Ice Age ~18 kyr BP. Notice that the transitions from Glacial (Ice Age) to Inter-Glacial appears to happen very rapidly. Zoom in on temperature anomalies and CO2 concentration from the time that Earth emerged form the last Ice Age period to enter the Holocene and up to 1998 (Year 0). Then, calculate the linear rates of change for temperature and CO2 concentration. We will want to use the actual temperature for the rate of change calculation, not the anomaly.
Do the following:
Use filter(Year_BP/1000 <= 18)
to select Vostok data from the last 18 000 years and then graph actual temperature (that's column: Temp_C_vost in vostok.temp) for the last 18 kyr, with point and line geom.
Estimate the rate of temperature change from 18-11 kyr ago.
Instead of using lm()
to determine the rate of temperature change, estimate the rate of change from the graph. Use the graph to visually estimate temperatature change from the approximate end of the last Ice age (18 000 yr ago) to the approximate start of the Holocene (11 000 yr ago). Then, calculate the rate of change.
For temperature, use the absolute value of the difference (Ie: ignore the negative number). Show how you used R to do the math and report the estimated rate of temperature change from 18-11 kyr ago, make sure to include units (hint: temp/time).
Compare the annual rate of temperature change from modern times (since 1880 to 1950) with the pre-historic rate of change from the last Ice Age Transition.
Graph actual Vostok temperatures from 18 kyr BP to present (1998):
[INSERT GRAPH]
Hint for rate of change estimate
Remember that the rate of change is given by the following formulas, and the relevant values can be visually estimated on a graph:
\(\frac{rise}{run} = \frac{change(y)}{change(x)} = \frac{y2-y1}{x2-x1}\)
Visually estimate and calculate rate of temperature change from 18 to 11 kyr ago. Remember the years are in the 1000's so use the 1000s numbers, not the ones shown on the graph!!:
[SHOW CALCULATION FOR VISUAL ESTIMATE OF TEMPERATURE CHANGE RATE]
Use modern atmospheric isotopic \(\delta\) 13C data to examine supporting evidence that the current rise in CO2 comes from fossil fuel emissions.
How do we know warming and rising CO2 are caused by humans?!
Evidence for climate change is based on data that includes what we have explored here. These meticulously gathered temperature and CO2 data show how temperature and CO2 fluctuate together. We can also use other data like the isotopic signature of CO2 in the atmosphere to determine whether rising CO2 in the atmosphere is consistent with isotopic signals we expect to see with increasing fossil-fuel contribution.
Do the following:
Graph modern \(\delta\) 13C:
[INSERT GRAPH, don't worry if you get this warning, it's because one data point is absent fro the full dataset. ##Warning: Removed 1 rows containing missing values (geom_point)]
Answer the following:
ggplot2 has some default built-in themes that can easily be added to make the figures look nicer. Themes are added to a ggplot like all the other elements, with a +
.
These two are nice alternatives to the gray background, you can try them:
+theme_bw()
+theme_linedraw()