OVERVIEW. Climate is the long-term description of weather, the latter defined by the atmospheric conditions at a particular time and location. As organisms experience particular atmospheric conditions daily, the climate shapes where and how organisms live. Thus, understanding how physical principles influence the global climate is key to describe and model phenomena in nature. Today, we will focus on temperature. Specifically, we will explore the basic physical principles of planet Earth that influence latitudinal patterns in temperature, and thus the distribution of organisms.
Student learning outcomes:
Materials:
Insolation is the solar radiation that reaches the Earth’s surface. Let’s first explore the relationship between insolation and latitude.
A. Import the “insol_temp” dataset to RStudio
Let’s import and explore the “insol_temp” data. For this, save the data file in your computer “as page source”.
# importing the data
insol_temp <- read.csv("insol_temp.csv",header=TRUE)
# viewing the data
View(insol_temp)
Questions:
B. Plot insolation as a function of latitude
Because this is a relationship involving two numerical variables, you need to use a scatter plot. Using the ggplot() and the geom_point() functions, indicate dataset, the column representing the x-axis (explanatory variable), and the column representing the y-axis (response variable). Note: negative latitudes represent the southern hemisphere (S) and positive latitudes represent the northern hemisphere (N).
# Loading package ggplot2
library(ggplot2)
# Plotting insolation as a function of latitude
p1 <- ggplot(insol_temp,aes(x=lat,y=insol)) +
geom_point()
p1
# adding aesthetics
p1 <- ggplot(insol_temp,aes(x=lat,y=insol)) +
geom_point() +
ylab("Insolation (kWh/m^2/day)") +
xlab("Latitude") +
theme_classic(15)
p1
Questions:
Now, let’s plot the mean insolation across latitude. To get a summary of descriptive statistics, including mean insolation per latitude, we use the function summarySE() in the Rmisc package. The first argument in this function is the dataframe, and the subsequent arguments are the name of the column containing the variable to be summarized (response variable) and the name of the column containing the grouping variable (explanatory variable).
# Installing the package Rmisc
install.packages("Rmisc",repos='http://cran.us.r-project.org')
# Loading package Rmisc
library(Rmisc)
# getting descriptive stats for insolation across latitude
sum <- summarySE(insol_temp,"insol","lat")
# checking the new object created
sum
Question:
# plotting the mean insolation across latitude
p2 <- ggplot(sum,aes(x=lat,y=insol)) +
geom_point() +
ylab("Mean insolation (kWh/m^2/day)") +
xlab("Latitude") +
theme_classic(15)
p2
# adding standard error bars
p3 <- p2 + geom_errorbar(aes(ymin=insol-se,ymax=insol+se))
p3
# adding a line to the plot using geom_line()
p4 <- p3 + geom_line()
p4
Question:
Now, let’s explore the relationship between temperature and latitude.
A. Plot temperature as a function of latitude
Challenge 1: Following Step 1B, plot the mean temperature and the variation around the mean across latitude.
Questions:
Now, let’s explore the association between insolation and temperature.
A. Carry out a correlation analysis between insolation and temperature.
To test the strength of the association between two numerical variables, we use a correlation analysis. This analysis estimates the linear correlation coefficient, r. The linear correlation coefficient measures the tendency of two numerical variables to change together along a line. The coefficient r takes values between -1 and 1. The closer r is from either -1 or 1, the stronger the correlation or the more the observations will lie under a line (Figure 1).
The R function cor() estimates the correlation coefficient r with the formula below.
\[ \begin{aligned} r=\frac{\sum_{i}(X_i-\overline{X})(Y_i-\overline{Y})}{\sqrt{\sum_{i}(X_i-\overline{X})^2}\sqrt{\sum_{i}(Y_i-\overline{Y})^2}}, \end{aligned} \]
where \(X\) and \(Y\) are the two numerical variables with \(i\) observations.
Let’s do a correlation analysis for insolation and temperature using the cor(). The first argument in the function is variable 1 (e.g., insol) and the second argument is variable 2 (e.g., temp). Note that you can use a dollar sign $ to indicate “within”.
# correlation coefficient
cor(insol_temp$insol,insol_temp$temp)
Questions:
B. Plot insolation versus temperature.
Finally, let’s visualize the association between insolation and temperature.
# plotting insolation versus temperature
p5 <- ggplot(insol_temp,aes(insol,temp)) +
geom_point() +
ylab("Insolation (kWh/m^2/day)") +
xlab("Temperature (°C)") +
theme_classic(15)
p5
Question:
Great Work!