[Solved] Using factor levels with geom_rect


I got some help after asking the same question on the comp.lang.r.general mailing list
(http://permalink.gmane.org/gmane.comp.lang.r.general/313656). I ended up adding the following:

nodelist <- sort(levels(flatdata$value))

and then using

geom_rect(aes(ymin=as.Date("8-Apr-2014", format="%d-%b-%Y"),
            ymax=as.Date("30-Apr-2014", format="%d-%b-%Y"),
            xmin=which(nodelist=="node004")-0.5,
            xmax=which(nodelist=="node004")+0.5,
            fill="red", alpha=0.25))

solved Using factor levels with geom_rect