[R] Multiple expressions, when using substitute()

Spencer Graves spencer.graves at pdf.com
Tue Oct 11 03:41:37 CEST 2005


	  Have you received a reply to this post?  I couldn't find one, and I 
couldn't find a solution, even though one must exist.  I can get the 
substitute to work in "main" but not "legend":

B <- 2:3
eB <- substitute(y==a*x^b, list(a=B[1], b=B[2]))
plot(1:2, 1:2, main=eB)

	  You should be able to construct it using "mtext", but I couldn't get 
the desired result using legend.

	  hope this helps.
	  spencer graves

John Maindonald wrote:

> expression() accepts multiple expressions as arguments, thus:
> 
> plot(1:2, 1:2)
> legend("topleft",
>                expression(y == a * x^b,
>                                     "where "* paste(y=="wood; ",  
> x=="dbh")))
> 
> Is there a way to do this when values are to be substituted
> for a and b? i.e., the first element of the legend argument
> to legend() becomes, effectively:
>    substitute(y == a * x^b, list(a = B[1], b=B[2]))
> 
> John Maindonald             email: john.maindonald at anu.edu.au
> phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
> Centre for Bioinformation Science, Room 1194,
> John Dedman Mathematical Sciences Building (Building 27)
> Australian National University, Canberra ACT 0200.
> 
> ______________________________________________
> R-help at 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.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list