[R] : bquote inside legend()

Monica Pisica pisicandru at hotmail.com
Mon Aug 11 18:30:04 CEST 2008


Hi,

I have a graph and I would like to write some values inside the legend that were saved in a variable. Please revise the code below in which I've wrote 2 different legends, but I am not happy with either of them. What I want is a legend with tile "Legend" and underneath a line with a name and a value like that: value = 2.

#Code begin:
# -------------------
a = 2	# result of a function for example
plot(1:10, a*(1:10))

legend(1, 20, c("Legend", bquote(value ==.(a))), bty = 'n')

val <- substitute("value" ==.(a), list(a = a))
legend(6, 5, do.call("expression",list("Legend", val)), bty = 'n')

# -------------------
# Code end

In the first legend I don't like that value == 2 instead of value = 2, in the second legend, obviously I don't like the period and the brackets around the value of a. 

Thanks for any help,

Monica


_________________________________________________________________


LM_WLYIA_whichathlete_us


More information about the R-help mailing list