From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>

Date: Sun 01 May 2005 - 17:25:14 EST

Date: Sun 01 May 2005 - 17:25:14 EST

Aleksey Naumov <naumov@buffalo.edu> writes:

> Dear List,

*>
**> I would like to plot a simple legend with two math expressions, e.g.
**>
**> plot(0)
**> 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.
*

Ick. One of those cases that suggests that our current substitute mechanisms don't quite cut it... However, try

i <- "A"; j <- "B"

e <- bquote(expression(sigma[.(i)],sigma[.(j)]))
plot(0)

legend(1,.5,eval(e))

legend(1,-.5,e) # for comparison

Thing is, substitute(expression(....),...) returns a call to the "expression" constructor, rather than the expression itself, so you need the eval().

-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Sun May 01 17:30:23 2005

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