I'm having trouble with this code:
``
##Call Packages##
library(ggplot2)
library(tidyverse)
library(ggpubr)
library(stats)
library(ggpmisc)
options(stringsAsFactors = FALSE)
setwd("/Users/davidowoods/Desktop/RainManSR/Data/NDVI")
##Import Data##
NDVIAverages <-
read.csv("/Users/davidowoods/Desktop/RainManSR/RainMan_NDVIAveragesbyTreatment.csv",
header = TRUE)
Date <- NDVIAverages$Time <- format(NDVIAverages$Time)
#plot S1##
png(filename = "NDVIS1.png")
S1 <- ggplot(data = NDVIAverages, aes(x = Date, y = S1)) +
geom_point(color='blue') +
geom_smooth(method = lm, formula = y ~ x, color = 'red', se = FALSE) +
stat_poly_eq(formula = y ~ x,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE)+
labs(x="Date", y="GPP", title="Average GPP for Treatment One")
print(S1) #print graph
dev.off()
``
When I run it I get this warning message:
Warning message: Computation failed in `stat_poly_eq()`: argument "x" is missing, with no default
I really don't know what is going on. It seems to me like x is defined in aes()