rrookie1982
2010-Jan-17 17:47 UTC
[R] plotting Formulas with greek letters and variable values (expression, substitute, paste, ...)
Hallo together, I want to write a formula of the type http://n4.nabble.com/file/n1016112/expression.gif into my plot, where the values 1.234 and -0.567 should origin from variables in the program. The threads in this forum gave me some ideas that the functions expression(), paste(), and substitute() will get me there but I just cannot figure out how to do it. The closest I got is: text(0,7.5,substitute(expression(paste(symbol("t"),"(A) = ",c1 + lg(A^c2),sep="")),list(c1=0,456,c2=-0.123)),pos=4) Thankful for any suggestions! Daniel -- View this message in context: http://n4.nabble.com/plotting-Formulas-with-greek-letters-and-variable-values-expression-substitute-paste-tp1016112p1016112.html Sent from the R help mailing list archive at Nabble.com.
Uwe Ligges
2010-Jan-17 18:02 UTC
[R] plotting Formulas with greek letters and variable values (expression, substitute, paste, ...)
On 17.01.2010 18:47, rrookie1982 wrote:> text(0,7.5,substitute(expression(paste(symbol("t"),"(A) = ",c1 + > lg(A^c2),sep="")),list(c1=0,456,c2=-0.123)),pos=4) >It is much easier, just write the formula down in R syntax and substitute the relevant variables as in: text(0, 7.5, substitute(tau(A) == a*lg(A^b), list(a=1.234, b=-0.567))) Best, Uwe Ligges
Gabor Grothendieck
2010-Jan-17 18:18 UTC
[R] plotting Formulas with greek letters and variable values (expression, substitute, paste, ...)
Try bquote: a <- 0.1; b <- 0.2 plot(0, main = bquote(tau(A) == .(a)*lg(A^.(b)))) On Sun, Jan 17, 2010 at 12:47 PM, rrookie1982 <desser1 at uni-bonn.de> wrote:> > Hallo together, > > I want to write a formula of the type > > http://n4.nabble.com/file/n1016112/expression.gif > > > > > > > > into my plot, where the values 1.234 and -0.567 should origin from variables > in the program. The threads in this forum gave me some ideas that the > functions expression(), paste(), and substitute() will get me there but I > just cannot figure out how to do it. The closest I got is: > > text(0,7.5,substitute(expression(paste(symbol("t"),"(A) = ",c1 + > lg(A^c2),sep="")),list(c1=0,456,c2=-0.123)),pos=4) > > Thankful for any suggestions! > Daniel > -- > View this message in context: http://n4.nabble.com/plotting-Formulas-with-greek-letters-and-variable-values-expression-substitute-paste-tp1016112p1016112.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
rrookie1982
2010-Jan-18 07:14 UTC
[R] plotting Formulas with greek letters and variable values (expression, substitute, paste, ...)
rrookie1982 wrote:> > I want to write a formula of the type > > http://n4.nabble.com/file/n1016112/expression.gif > > into my plot, where the values 1.234 and -0.567 should origin from > variables in the program. >Uwe Ligges-3 wrote:> > It is much easier, just write the formula down in R syntax and > substitute the relevant variables as in: > > text(0, 7.5, substitute(tau(A) == a*lg(A^b), list(a=1.234, b=-0.567))) >Gabor Grothendieck wrote:> > Try bquote: > > a <- 0.1; b <- 0.2 > plot(0, main = bquote(tau(A) == .(a)*lg(A^.(b)))) >Wow, those two examples are indeed much simpler than my tries and work just fine. Now I just will have two choose which way to go:> suba <- 1.234; subb <- -0.567 > text(0, 5,substitute(tau(A) == a*lg(A^b), list(a=suba, b=subb)),pos=4) ## > and > text(0, 5,bquote(tau(A) == .(suba)*lg(A^.(subb))),pos=4)both work exactly how I wanted them to do. Thank you Uwe and Gabor -- View this message in context: http://n4.nabble.com/plotting-Formulas-with-greek-letters-and-variable-values-expression-substitute-paste-tp1016112p1016416.html Sent from the R help mailing list archive at Nabble.com.