[R] Plotmath with values?

Mike Prager mike.prager at noaa.gov
Wed Dec 31 17:47:06 CET 2008


I hope to use the plotmath facility to print titles that mix
math and values of R variables.

The help for "plotmath" has an example, which after repeated
reading, I find baffling. Likewise, I have read the help file
for "substitute" (wqhich seems to be needed) without ever
understanding what it does, other than being used in some magic
incantations. 

I would like to do something like this:

     dev.new()
     aa <- round(pi,2)
     plot(1:3, 1:3, main = ~ a == aa)

and have the main title read "a = 3.14"

but of course it reads "a = aa".

>From a user's point of view -- one who has never written a
parser nor taken a course in compilers -- what is needed is the
nonexistent function "value" usable in plotmath expressions to
produce the value of its argument, as 

     plot(1:3, 1:3, main = ~ a == value(aa))

How can this be done?

THANKS!

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.



More information about the R-help mailing list