I have 4 time series plots on the same graph and I want to fit a trendline on all. I used ggplot and added the remaining two plots with the geom_line sub-function. When I used the geom_smooth function to fit the equation line, it only does it for the first graph leaving the other 2. Please, this is the link to the file I used for the code (https://drive.google.com/open?id=16k1cMMr1dthJOsppazVZ3cUCa1rRGF9m) and below is the code.
nf <- read.csv("F:/Project work/Publication/Under writing/Heat stress/nf_tas.csv", sep = ",", header = TRUE) nf$date_mpi <- as.Date(as.character(nf$date_mpi)) nfu <- ggplot(data = nf, aes(x=nf$date_mpi, y=nf$mpi_nf))+ labs(title = "Annual temperature trends", x="Near-future projection", y="Temperature [°C]")+ scale_y_continuous(limits = c(24,31)) + geom_line(aes(y=nf$mpi_nf, color='WRF-MPI-ESM MR'))+ geom_line(aes(y=nf$hadgem_nf, color='WRF-HadGEM2-ES'))+ geom_line(aes(y=nf$gfdl_nf, color='WRF-GFDL-ESM2M'))+ theme(legend.position = c(.1,.85)) nfu + theme(text = element_text(size = 12)) #> Error in eval(expr, envir, enclos): object 'nfu' not found
Created on 2020-03-22 by the reprex package (v0.2.1)
I'd appreciate if I could be assisted in this regard.