Adding titles to loop graph R
<p>Im trying to loop a lot of graphs in R. The code im using looks like this: </p>

<pre><code>#--------------------------------------------------------------------
#### Read data &amp; Converting factors ####
dat &lt;- read.table("Complete RING.txt", header =TRUE)  
str(dat)
dat$Vial &lt;- as.factor(dat$Vial)
dat$Line &lt;- as.factor(dat$Line)
dat$Fly &lt;- as.factor(dat$Fly)  
dat$Temp &lt;- as.factor(dat$Temp)
str(dat)


meltet &lt;- melt(dat, id=c("Concentration","Sex","Line","Vial", "Fly", "Temp", "Vial_nr"))
meltet1 &lt;- subset(meltet, Line=="20")
meltet1$variable &lt;- as.factor(meltet1$variable)

AllConcentrations &lt;- levels(unique(meltet1$Concentration))
for (i in AllConcentrations) {
meltet.i &lt;- meltet1[meltet1$Concentration ==i,]
quartz()
print(dotplot(value~variable|Temp, group=Sex, data = meltet.i ,xlab="Time", ylab="Fly position", main=paste("Line 20 concentraion", AllConcentrations[i]))) }
</code></pre>

<p>The concentrations im using are denoted A, B, C, D, E, X and Y - how do i add a title to the plot that changes with the plots, i have tried to use the main=" " function but then i get the same name in each graph. The title i get now is: Line 20 concentration NA in each graph</p>

<p>EDIT: 
updated the code</p>