ivo_welch-rstat8783@mailblocks.com
2004-Jul-29 23:37 UTC
[R] expression + paste + arguments + ...
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 } 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
I don't know latex, but have you looked at "?plotmath", including 'demo(plotmath)', the examples in the documentation, and an R site search suggested in the posting guide (http://www.R-project.org/posting-guide.html)? What you want is probably fairly easy, once you parse the "plotmath" documentation. hope this helps. spencer graves 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 } > > 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
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