I cant figure out how to place two correlation lines for each data.frame in R. Code looks like:
combinedplot <- ggplot() +
geom_point(data = data.frame1, aes(x=variable1, y=variable2, color='red')) +
geom_point(data = data.frame2, aes(x=variable1, y=variable2, color='blue')) +
labs(x="Date", y="PM 2.5 ugm3")
combinedplot
I have also tried
combinedplot <- ggplot() +
geom_point(data = data.frame1, aes(x=variable1, y=variable2, color='red')) +
geom_point(data = data.frame2, aes(x=variable1, y=variable2, color='blue')) +
labs(x="Date", y="PM 2.5 ugm3")
combinedplot + geom_smooth(method='lm')
And
combinedplot <- ggplot() +
geom_point(data = data.frame1, aes(x=variable1, y=variable2, color='red')) +
geom_smooth(method='lm') +
geom_point(data = data.frame2, aes(x=variable1, y=variable2, color='blue')) +
geom_smooth(method='lm') +
labs(x="Date", y="PM 2.5 ugm3")
combinedplot
Both options just print the graph without the lines, any suggestions?