[R] legend/plotmath/substitute problem
Philipp Pagel
p.pagel at gsf.de
Fri Dec 15 00:33:31 CET 2006
On Thu, Dec 14, 2006 at 06:25:49PM -0500, Duncan Murdoch wrote:
> 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:
Thanks a lot! Learned something, again.
cu
Philipp
--
Dr. Philipp Pagel Tel. +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186
Technical University of Munich
85350 Freising, Germany
http://mips.gsf.de/staff/pagel
More information about the R-help
mailing list