I am trying to fit a linear regression (9 of them actually) through a figure that has 20 facets. Every time I fit the regression (using geom_smooth using method = lm), it fits 20 lines, one through each facet, however I would like the one line for each ReefSpecies combination to go through all 20 facets.
Here is my figure:
Here is what I have so far:
Biomass <- c(20, 10, 5, 4, 5, 7, 8, 22, 13, 13, 15, 18, 2, 5, 7, 10)
Season <- c("Winter", "Spring", "Summer", "Fall")
Year <- c("1", "2", "3", "4")
ReefSpecies <- c("Admiral Ma", "Jaap Mf", "Grecian Ma", "Alligator Mf", "Jaap Mf", "Grecian Ma", "Alligator Mf", "Admiral Ma", "Grecian Ma", "Alligator Mf", "Admiral Ma", "Jaap Mf", "Alligator Mf", "Admiral Ma", "Jaap Mf","Grecian Ma")
Seasonal <- data.frame(Biomass, Season, Year, ReefSpecies)
testp <- ggplot(data = Seasonal, aes(x = Season, y = Biomass, group = ReefSpecies, fill = ReefSpecies, colour = ReefSpecies))
testp <- testp + geom_point(stat = "identity", position="identity", inherit.aes = TRUE)
testp <- testp + facet_grid(. ~ Year, scales="fixed")
testp <- testp + theme(axis.text.x = element_text(angle = 90))
testp <- testp + theme(panel.margin.x = unit(0, "lines"))
testp <- testp + theme(legend.position = "top")
testp