[R] Lattice: key with expression function
deepayan.sarkar at gmail.com
deepayan.sarkar at gmail.com
Wed Sep 5 20:27:09 CEST 2007
On 9/5/07, Folkes, Michael <FolkesM at pac.dfo-mpo.gc.ca> wrote:
> HI all,
> I'm trying (unsuccessfully) to add the degree symbol to each line of
> text in my legend (within xyplot).
> Here is the line of code, which fails to interpret the expression
> function:
>
> auto.key =list(points =
> FALSE,text=paste(levels(as.factor(divertSST2$temp)),expression(degree)).
> ..),
>
> I just get:
> 7 degree
> 8 degree
> 9 degree
That's because
> paste("foo", expression(degree))
[1] "foo degree"
> If I place 'expression' outside or just after the paste function it also
> doesn't work.
auto.key = list(text = expression(paste("foo", degree)))
should work. I think the problem is that you want a vector of
expressions, and that's a bit harder to get. I'm not sure what the
best solution is, but if everything else fails, you could try using
parse(text=)
-Deepayan
More information about the R-help
mailing list