[R] expression + paste + arguments + ...

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jul 30 09:00:51 CEST 2004


ivo_welch-rstat8783 at mailblocks.com wrote:

> 
> dear R wizards:  I would like to write a function that roughly places 
> the equivalent of the following latex text into the current plot:
> 
>   \newcommand{ \placesigma }[4]{ \put(\#1,\#2){ \sigma_{A , #3} = #4 }

???
You are "just" defining a new LaTeX command ... nothing will be printed 
in LaTeX.


Instead of using \put, you can specify coordinates as usual in R using 
text(), title() or mtext().
Instead of "\sigma_{A , #3} = #4", you can use

   substitute(sigma[v3] == v4, list(v3 = paste("A,",v3), v4 = v4))

which leads to, e.g.

   plot(1:10)
   v3 <- 99
   v4 <- 55
   text(4, 1, label = substitute(sigma[v3] == v4,
                  list(v3 = paste("A,",v3), v4 = v4)))

See also ?plotmath and the R Help Desk Column in R News 2 (3).

Uwe Ligges


> I cannot figure out how to do this.  I know I have to use a function 
> that uses expressions in a text() invoke.  But passing arguments and 
> nesting strings and expressions has so far not worked for me.  I hope 
> this is an obvious question---if not, please just tell me and I can give 
> up.  help appreciated.
> 
> sincerely,
> 
> /iaw
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list