Another question: how do you add the equation and r^2 value of the line onto the graph?
``
##Call Packages##
library(ggplot2)
library(tidyverse)
library(ggpmisc)
options(stringsAsFactors = FALSE)
##Set Directories##
setwd("/Users/davidowoods/Desktop/RainManSR/Data/GPP")
IN_dir="/Users/davidowoods/Desktop/RainManSR/Data/GPP/RainMan_GPPAveragesbyTreatement_Woods.csv"
OUT_dir= "/Users/davidowoods/Desktop/RainManSR/Data/GPP/Figures"
##Import Data##
df <- read.csv(IN_dir, header = TRUE)
GPPAverages <- na.omit(df)
View(GPPAverages)
##Plot S1##
GPPAverages$Date = lubridate::ymd(GPPAverages$Date)
S1 <- ggplot(data = GPPAverages, aes(x = Date, y = S1Average)) +
geom_point(color='blue') +
geom_smooth(method = lm, formula = y~x, color = 'red', se = FALSE) +
stat_poly_eq()+
labs(x="Date", y="GPP", title="Average GPP for Treatment One")
print(S1) #print graph
##Plot S2##
S2 <- ggplot(data = GPPAverages, aes(x = Date, y = S2Average)) +
geom_point(color='blue') +
geom_smooth(method = lm, formula = y~x, color = 'red', se = FALSE) +
labs(x="Date", y="GPP", title="Average GPP for Treatment Two")
print(S2) #print graph
##Plot S3##
S3 <- ggplot(data = GPPAverages, aes(x = Date, y = S3Average)) +
geom_point(color='blue') +
geom_smooth(method = lm, formula = y~x, color = 'red', se = FALSE) +
labs(x="Date", y="GPP", title="Average GPP for Treatment Three")
print(S3) #print graph
##Plot S4##
S4 <- ggplot(data = GPPAverages, aes(x = Date, y = S4Average)) +
geom_point(color='blue') +
geom_smooth(method = lm, formula = y~x, color = 'red', se = FALSE) +
labs(x="Date", y="GPP", title="Average GPP for Treatment Four")
print(S4) #print graph
``