An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091112/95c6666b/attachment-0001.pl>
Substituting vectors into a legend
2 messages · Bob O'Hara, David Winsemius
On Nov 12, 2009, at 4:59 AM, Bob O'Hara wrote:
I have a simple (!) problem. What I want to do is to create a
legend with
Greek letters, and substituting numbers into the legend. Like this:
mu=1:3
Mean=rep(mu, each=20)
plot(runif(60), rnorm(60,Mean,0.1), pch=Mean) # create a plot
legend(0.6,1.7, paste("mu =", 1:3), pch=mu)
but with a Greek letter mu.
# First:
library(fortunes)
fortune("dog")
Searching in R-search reveals that Bill Dunlap has offered a few
solutions to prior such questions. This is an adaptation of the
shortest solution from:
http://finzi.psych.upenn.edu/Rhelp08/2009-August/209677.html
mu1=1:3 #
Mean=rep(mu1, each=20)
plot(runif(60), rnorm(60,Mean,0.1), pch=Mean) # create a plot
legend(0.6,1.7, as.expression(lapply(mu1, function(m) bquote(mu==.
(m)))), pch=mu1)
David > > I think the solution has something to do with substitute() possibly > along > with and eval(), paste() and probably a few other functions. But > the help > page is remarkably unhelpful: it seems to have been written for > people who > work with the underlying code, and not for us mere mortals. Could > someone > explain how to do this? > > Bob > > -- > Bob O'Hara > > Biodiversity and Climate Research Centre > Senckenberganlage 25 > D-60325 Frankfurt am Main, > Germany > > Tel: +49 69 798 40216 > Mobile: +49 1515 888 5440 > WWW: http://www.RNI.Helsinki.FI/~boh/ > Blog: http://network.nature.com/blogs/user/boboh > Google Wave: rni.boh at googlewave.com > Journal of Negative Results - EEB: www.jnr-eeb.org > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT