On 12/14/2006 5:05 PM, Philipp Pagel wrote:
My problem starts, when I want to put more than one series of data in
the plot and accordingly need one legend row per data series:
year1 = 2001
year2 = 2005
g1 = 1.9
g2 = 1.7
plot(1)
legend('top',
legend=c(
substitute(paste(year, ': ', gamma, '=', g),
list(year=year1, g=g1)),
substitute(paste(year, ': ', gamma, '=', g),
list(year=year2, g=g2))
)
)
This obviously does not produce the desired result. Apparently, I am not
generating a list of expressions, as intended. So I thought, maybe R uses a
variety of the recycling rule here and tried:
The problem is that legend wants an expression, but substitute() isn't
returning one, it's returning a call, and c(call1,call2) produces a list
of two calls, not an expression holding two calls. So the following
would work, but there might be something more elegant: