I'm working with data from all 50 states. I'm trying to chart small multiple line charts with one line being the state (blue) and the other as the national average (gray).
Here is an example for Maine:
Here is what my data frame for Maine looks like:
I'm trying to shade the areas where the state line falls below the national average red and when it is above it green.
I've used geom_ribbon to shade the area and get one color (scale is different):

However, I'm struggling to find a way to change the fill when the state line crosses the national line.
When I run this code:
ggplot(states, aes(x = year, group=1)) +
geom_line(aes(y = ttc_avg),colour='#006f91') +
geom_line(aes(y = nat_avg), colour='#666666') +
geom_ribbon(aes(x=year, ymin = nat_avg, ymax = ttc_avg, fill=ttc_avg > nat_avg)) +
scale_fill_manual(values=c("green", "red"), name="fill") +
facet_wrap(~state)
I get an error that says Aesthetics can not vary with a ribbon.
What is the best way to tackle this? Should I be using geom_ribbon or another ggplot2 function?

