No error message getting when trying to add a legend however not getting the legend in plot.
ggplot(Rent1, aes(Date, Rent))+
geom_point(size=3, shape=16)+
geom_smooth(method = "lm", formula = y~poly(x,1), se = F) +
geom_smooth(method = "lm", formula = y~poly(x,3), se = F, color = "red") +
theme_economist() +
theme_bw()+
coord_cartesian(ylim = c(0, 60)) +
stat_regline_equation(label.y=55) +
stat_cor(aes(label=..rr.label..), label.y=50)+
labs(title = "Market Condition", x = "Sign Date", y = "Rent Per SF")+
theme(plot.title = element_text(hjust = 0.5))+
legend(0, 50, legend=c("Linier Trend", "3rd Order Polynomial Trend"), col = c("blue", "red"), lty=1:2, cex=0.8, box.lty=2, box.lwd=2, box.col="green")
Rent1
No `Lease \r\nCenter \r\nAddress` Date GLA Rent YearBuilt Population MedianI…¹ Housi…² Total…³
1 1 Kohl's 2008-01-01 75000 25 1977 278238 69974. 105743 7.40e 9
2 2 Lowe's 2009-07-01 107000 24 2010 2263730 78283. 955038 7.48e10
3 3 Burlington Coat Factory 2010-05-01 87410 8.01 1986 1752655 97846. 623456 6.10e10
4 4 Nordstrom Rack 2010-08-01 35000 18.6 2009 1893161 93244. 650745 6.07e10
5 5 Target 2011-04-01 99677 23 1999 2220210 76616. 935856 7.17e10
6 6 Safeway 2011-10-01 65000 32.5 2012 1756357 101087. 637714 6.45e10
7 7 Dick's Sporting Goods 2013-01-01 84060 28.0 1968 1545600 81051. 667701 5.41e10
8 8 Costco 2013-03-01 147721 21 1998 2879507 59267. 988139 5.86e10
9 9 Food 4 Less 2013-09-01 80000 24.5 1992 5050412 55164. 1875950 1.03e11
10 10 Ross Dress for Less 2013-10-01 160088 40.3 2006 1039775 57151. 329405 1.88e10
11 11 Equinox 2014-01-01 114010 41.6 2001 2220210 76616. 935856 7.17e10