My data looks like this example:
    dataExample<-data.frame(Time=seq(1:10),
        Data1=runif(10,5.3,7.5),
        Data2=runif(10,4.3,6.5),
        Application=c("Substance1","Substance1","Substance1",
        "Substance1","Substance2","Substance2","Substance2",
        "Substance2","Substance1","Substance1"))
        dataExample
           Time    Data1    Data2 Application
        1     1 6.511573 5.385265  Substance1
        2     2 5.870173 4.512775  Substance1
        3     3 6.822132 5.109790  Substance1
        4     4 5.940528 6.281412  Substance1
        5     5 7.269394 4.680380  Substance2
        6     6 6.122454 6.015899  Substance2
        7     7 5.660429 6.113362  Substance2
        8     8 6.649749 4.344978  Substance2
        9     9 7.252656 4.764667  Substance1
        10   10 7.204440 5.835590  Substance1
I would like to indicate at which time any Substance was applied that is different from dataExample$Application[1].
Here I show you the way I get this ploted, but I assume that there is a much easier way to do it with ggplot.
library(reshape2)
library(ggplot)
plotDataExample<-function(DataFrame){
  longDF<-melt(DataFrame,id.vars=c("Time","Application"))
  p=ggplot(longDF,aes(Time,value,color=variable))+geom_line()
  maxValue=max(longDF$value)
  minValue=min(longDF$value)
  yAppLine=maxValue+((maxValue-minValue)/20)
  xAppLine1=min(longDF$Time[which(longDF$Application!=longDF$Application[1])])
  xAppLine2=max(longDF$Time[which(longDF$Application!=longDF$Application[1])])
  lineData=data.frame(x=c(xAppLine1,xAppLine2),y=c(yAppLine,yAppLine))
  xAppText=xAppLine1+(xAppLine2-xAppLine1)/2
  yAppText=yAppLine+((maxValue-minValue)/20)
  appText=longDF$Application[which(longDF$Application!=longDF$Application[1])[1]]
  textData=data.frame(x=xAppText,y=yAppText,appText=appText)
  p=p+geom_line(data=lineData,aes(x=x, y=y),color="black")
  p=p+geom_text(data=textData,aes(x=x,y=y,label = appText),color="black")
  return(p)
}
plotDataExample(dataExample)

Question: Do you know a better way to get a similar result so that I could possibly indicate more than one factor (e.g. Substance3, Substance4 ...).
