I've got a dataframe that looks like:
df<-data.frame(Date=as.Date(c("06-08-10","06-09-10","06-10-10","06-11-10","06-13-10")),closed_this_year_cum_gv=c(3,5,6,7,NA),opened_this_year_cum_gv=c(2,5,6,8,10),closed_last_year_cum_gv=c(5,6,7,8,10),opened_last_year_cum_gv=c(5,6,8,10,NA))
and have this framework for a plot using ggplot2:
ggplot(df, aes(x=Date))+
geom_line(aes(y=closed_this_year_cum_gv, color="blue"),linetype="dashed")+
geom_line(aes(y=opened_this_year_cum_gv, color="blue"))+
geom_line(aes(y=closed_last_year_cum_gv, color="red"),linetype="dashed")+
geom_line(aes(y=opened_last_year_cum_gv, color="red"))+
xlab("Date")+
ylab("Millions of Dollars")+
ggtitle("Cummulative Sum of TGV for Opened and Closed Cases - 2013 vs. 2012")
I tried this with the sample data but for some reason the lines aren't showing up (they're showing up with my real data). I want the NAs to not be graphed, which is why they aren't 0.
In my real data, it graphs, but the legend title has "blue" and it's contents are "blue" and "red" as labels. I want them to be labeled by year and opened/closed. I've tried various methods but nothing seems to override the legend.
How do I control the legend title and labels?
Edit: changed to class "Date"