title: How to combine character (or numeric) variables with expressions at LEGEND in R
body: <p>When using R to plot three lines with legend that combines expression and character variables, I wrote, for example:</p>
  
  <pre><code>b1&lt;-2
  c1&lt;-3
  d1&lt;-4
  a&lt;-seq(1,10)
  b&lt;-a+b1
  c&lt;-a+c1
  d&lt;-a+d1
  
  plot(NA
   ,axes = FALSE       
   ,xlim=c(0,10)
   ,ylim=c(0,15)
   )
  box()
  
  lines(a,b,col=1)
  lines(a,c,col=2)
  lines(a,d,col=3)
  
  legend(8,2
  ,c(expression(paste(italic(b)[1],"=2","m"))
  ,expression(paste(italic(c)[1],"=3","m"))
  ,expression(paste(italic(d)[1],"=4","m"))
    )
        )
  </code></pre>
  
  <p>The above scripts yields exactly the legend I want, However, the value b1, c1 and d1 are hard coded in the script. </p>
  
  <p>Is there any way to put variable b1, c1 and d1 in the legend script? I have tried many ways, such as </p>
  
  <p>no1.</p>
  
  <pre><code>b2&lt;-as.character(b1)
  legend(6,2
  ,c(expression(paste(italic(b)[1],b2,"m"))
  ,expression(paste(italic(c)[1],"=3","m"))
  ,expression(paste(italic(d)[1],"=4","m"))
    )
        )
  </code></pre>
  
  <p>no2.</p>
  
  <pre><code>legend(4,2
   ,c(bquote(paste(italic(b) [1], "=",.(b1),"m" ))
  
  ,expression(paste(italic(c)[1],"=3","m"))
  ,expression(paste(italic(d)[1],"=4","m"))
    )
        )
  </code></pre>
  
  <p>this one works for the first line, but if I make three lines by bquote, it doesn't work anymore:</p>
  
  <pre><code>legend(2,2
   ,c(bquote(paste(italic(b) [1], "=",.(b1),"m" ))
  
  ,bquote(paste(italic(b) [1], "=",.(b1),"m" ))
  ,bquote(paste(italic(b) [1], "=",.(b1),"m" ))
    )
        )
  </code></pre>
  
  <p>Any great ideas? Many thanks in advance!</p>