I am trying to plot a regression line for how the wing length for a species of birds looks like over a year. I am using data from multiple years but I want to compress data from all years to only show the change of day of the year. For this I have taken the date and reformated it to only include month and day:
date <- format(BIRD$DATUM, "%b %d")
I have then attempted to define what coefficients it will use when running the plot:
coefs <- coef(lm(WING~ date, data = SISKIN))
Finally I have the code for the plot:
ggplot(BIRD, aes(date, WING, group = date)) +
geom_boxplot(fill="white", color="black", width= 0.8) +
ggtitle("BIRD DOY") +
ylab("Wing length (mm)") +
theme(axis.title = element_text(size = 9)) +
stat_summary(fun = mean, color="red", geom = "point") +
theme(axis.text= element_text(size= 7, angle = 0)) +
geom_abline(intercept = coefs, slope = coefs, color = "red")
Once I run this, the regression line only shows the relationship between the first and second data entry disregarding all other points. I want it to include all points.
BONUS: I also want to sequence the x-axis so that it is not so cluttered.
Dummy of data: