Skip to content
Prev 106190 / 398506 Next

legend/plotmath/substitute problem

On 12/14/2006 5:05 PM, Philipp Pagel wrote:
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:

year1 = 2001
year2 = 2005
g1 = 1.9
g2 = 1.7
plot(1)
legend('top',
	legend=c(
		as.expression(substitute(paste(year, ': ', gamma, '=', g), 
list(year=year1, g=g1))),
		as.expression(substitute(paste(year, ': ', gamma, '=', g), 
list(year=year2, g=g2)))
	)
)

Duncan Murdoch