[R] Catenating expressions in plotmath().

Paul Murrell p.murrell at auckland.ac.nz
Tue Mar 19 23:42:41 CET 2002


Hi


> I want to do something like produce a plot title of the form
>
> ``Sample size n = 42; critical value k_0 = 17.''


Does this do the trick ... ?

     nn <- 42
     kk <- 17
     plot(1:10,1:10,
           main=substitute(paste("Sample size ", n==nsub,
               "; critical value ", k[0]==ksub, "."),
               list(nsub=nn,ksub=kk), "."))

Paul


> where the ``n'' is to be in a maths font and ``k_0'' indicates
> that the 0 is a subscript.  (A la LaTeX.)
>
> But the values ``42'' and ``17'' are to be substituted in from the
> numeric values of R objects.
>
> After a bit of struggle I found that
>
> > nn <- 42
> > kk <- 17
> > plot(1:10,1:10,
>        main=substitute(list(n==nsub~~k[0]==ksub),list(nsub=nn,ksub=kk)))
>
> gets pretty close to what I want.  But how do I fold in the text strings
> ``Sample size'', "; critical value", and "." (at the end)?
>
> Is this simply impossible?
>
> I'd like to be able to do something like form
>
> e1 <- substitute(list(n==nsub),list(nsub==nn))
> e2 <- substitute(list(k[0]==ksub),list(ksub==kk))
>
> and then somehow ``paste'' together "Sample size", e1, "; critical value",
> e2, and ".".
>
> I've tried every possible permutation (I think) of expression(), paste(),
> and substitute(), and none seem to work.
>
> Is it a hopeless case?
>
> cheers,
>
> Rolf Turner
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
> r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list