[R] Combining math and variables in expression
Greg.Snow at imail.org
Wed Mar 11 17:25:51 CET 2009
> tmp <- '120.000'
> mtext(bquote( '100% Area' == .(tmp)~km^2 ))
Hope this helps,
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of socrates
> Sent: Wednesday, March 11, 2009 8:08 AM
> To: r-help at r-project.org
> Subject: [R] Combining math and variables in expression
> I am trying to get the following line in a plot margin using mtext:
> 100% Area = 120.000 km^2
> Where I intend that "100% Area =" is text, 120.000 is a number that
> according to different data, and km^2 should be a neat
> The expression function fails me, since it apparently cannot coerce an
> expression when a variable is involved.
> In the R help file there is an example using either bquote or
> substitute to
> accomplish like things, but these are sufficiently different from my
> objective and I am becoming more and more confused by every further
> I stumble on.
> This should be easy. Can anyone help me prevent spending anoter 2.5
> hours on
> the matter? Thanks.
> View this message in context: http://www.nabble.com/Combining-math-and-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help