I'm endeavoring to add a legend after creating a ggplot showing regression lines. I used the following code, which creates the plot, but doesn't seem to give me any option to add a legend. (It appears geom_abline automatically sets show.legend to FALSE if you specify a particular slope or intercept.) Can someone advise the best way to do this? Appreciate your advice.
Legends are usually added by setting an aesthetic in the mapping with the aes() function.
ggplot(DF, mapping = aes(x = Date, y = Value, color = GRP)) + ...
That would make a legend mapping the colors to the values of the GRP column.
Can you explain more about your data and what you are trying to do? A toy example of your data would also be very helpful. You can post data here using the output of the dput() function or you can constrict a small data set using the data.frame() function.