[R] legend(): how to put variable in subscript?

From: Aleksey Naumov <naumov_at_buffalo.edu>
Date: Sun 01 May 2005 - 06:28:24 EST

Dear List,

I would like to plot a simple legend with two math expressions, e.g.

legend(1, 0.5, expression(sigma[i], sigma[j]))

The difficulty is that i and j should be variables rather than strings "i" and "j". In other words I'd like to do something like:

i = "A"
j = "B"
legend(1, 0.5, expression(sigma[i], sigma[j]))

and have "A" and "B" as the actual subscripts. I can substitute the variable in the expression e.g.:

legend(1, 0.5, substitute(sigma[i], list(i='A', j='B'))) legend(1, 0.5, bquote(sigma[.(i)]))

however, this gives me just one of the two entries in the legend. I cannot figure out how to include both sigmas in the legend.

What would be the best way to do something like this? Thank you for your ideas or suggestions.


Aleksey Naumov
Department of Geography

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sun May 01 10:35:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:31 EST