giss = read.csv("giss_temp.csv")My Second Quarto Document: Module 05
Introduction
In module05, we walked through control statements in R. We also used the giss_temp.csv file for this lab.
One exercise involved modifying an “ifelse” statement. The original statement generated a vector of colors dependent on whether the temperature anomaly was above or below zero. The exercise required that I modify this statement to generate a vector of colors dependent on whether the year is before or after 1980.
Here, I am recreating the code I wrote for this exercise as a demonstration of my Quarto abilities.
Setting up
First, let’s load in the data:
Next, let’s create a couple of variables, one called “allyears”, and one called “ann_temp”
allyears = unique(giss$Year)
ann_temp = tapply(giss$TempAnom, giss$Year, mean)ifelse statement
Now that we have done the necessary preparation, I am going to modify the “ifelse” statement to reflect the assignment guidelines and create a plot detailing my results:
mycols = ifelse(allyears > 1980, "pink", "brown")
plot(allyears, ann_temp, type = 'h',
col = mycols, lwd = 3,
xlab= "Year", ylab = "T anomaly")Et voila, we have a table.
Thanks for reading!