Markus Loecher
2010-Mar-10 13:52 UTC
[R] expression(), mixed symbols and evaluated objects
Is it possible to mix symbols and evaluated objects inside the expression() function ? The following example shows what I am trying to achieve: for (m in 1:3) { plot(1:10); #just a place holder for the real plots title(expression(y = m * lambda)); } I want to actually evaluate the variable m but keep lambda as a symbol in the title. I tried to wrap an eval() around various subparts of the expression but to no avail. Going further, I ideally would like to mix text into the expression as well. Any help would be appreciated. Thanks, Markus [[alternative HTML version deleted]]
Duncan Murdoch
2010-Mar-10 14:12 UTC
[R] expression(), mixed symbols and evaluated objects
On 10/03/2010 8:52 AM, Markus Loecher wrote:> Is it possible to mix symbols and evaluated objects inside the expression() > function ? > The following example shows what I am trying to achieve: > > for (m in 1:3) { > plot(1:10); #just a place holder for the real plots > title(expression(y = m * lambda)); > } > > I want to actually evaluate the variable m but keep lambda as a symbol in > the title. > I tried to wrap an eval() around various subparts of the expression but to > no avail. > > Going further, I ideally would like to mix text into the expression as well. > > Any help would be appreciated.Use bquote. It returns an expression after evaluating only the parts wrapped in ".()". For example, for (m in 1:3) { plot(1:10); #just a place holder for the real plots title(bquote(y == .(m) * lambda)); } Duncan Murdoch