Module 6

Author

Doahn Lee

First Report

A first example of generating a report using R, RStudio and Quarto. The goal of this report is to:

  • Generate a simple report
  • Include some R code
  • Include a figure generated by R
5+6
[1] 11

Making Plots

giss = read.csv("giss_temp.csv", stringsAsFactors = TRUE)
summary(giss)
      Year          Month          DecDate        TempAnom        
 Min.   :1881   Min.   : 1.00   Min.   :1881   Min.   :-0.860000  
 1st Qu.:1913   1st Qu.: 3.75   1st Qu.:1914   1st Qu.:-0.210000  
 Median :1946   Median : 6.50   Median :1946   Median :-0.050000  
 Mean   :1946   Mean   : 6.50   Mean   :1946   Mean   :-0.009427  
 3rd Qu.:1979   3rd Qu.: 9.25   3rd Qu.:1979   3rd Qu.: 0.150000  
 Max.   :2011   Max.   :12.00   Max.   :2012   Max.   : 0.880000  
allyears = unique(giss$Year)
nyears = length(allyears)
ann_temp = mycols = rep(NA, nyears)
for (i in 1:nyears) {
  ann_temp[i] = mean(giss$TempAnom[giss$Year == allyears[i]])
  if (ann_temp[i] > 0) {
    mycols[i] = "red"
  } else {
    mycols[i] = "blue"
  }
}
plot(allyears, ann_temp, type = 'h', 
     col = mycols, lwd = 3,
     xlab= "Year", ylab = "T anomaly")

mycols = ifelse(ann_temp > 0, "orange", "purple")
allyears = unique(giss$Year)
ann_temp = tapply(giss$TempAnom, giss$Year, mean)
mycols = ifelse(allyears < 1980, "orange", "purple")
plot(allyears, ann_temp, type = 'h', 
     col = mycols, lwd = 3,
     xlab= "Year", ylab = "T anomaly")