Hi all, I have a question about expression. In a figure I want to include the term D*obs with the star as as superscript and obs as subscript. I have even just tried to get the star to be superscript. The code I tried was text(Dstar+7,120,expression(paste({}D,^*))), but that doesn't work and I get a syntax error. I can't seem to find anything in the help files that explains it. Thanks in advance. Cameron Guenther, Ph.D. 100 8th Ave. SE St. Petersburg, Fl 33701 727-896-8626 ext. 4305 cameron.guenther at myfwc.com
Try: plot(1, main = ~ D[obs]^"*") On 11/30/06, Guenther, Cameron <Cameron.Guenther at myfwc.com> wrote:> Hi all, > I have a question about expression. > > In a figure I want to include the term D*obs with the star as as > superscript and obs as subscript. I have even just tried to get the > star to be superscript. > > > The code I tried was > text(Dstar+7,120,expression(paste({}D,^*))), but that doesn't work and I > get a syntax error. > > I can't seem to find anything in the help files that explains it. > > Thanks in advance. > > Cameron Guenther, Ph.D. > 100 8th Ave. SE > St. Petersburg, Fl 33701 > 727-896-8626 ext. 4305 > cameron.guenther at myfwc.com > > > ______________________________________________ > R-help at stat.math.ethz.ch 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. > > >
Guenther, Cameron wrote:> The code I tried was > text(Dstar+7,120,expression(paste({}D,^*))), but that doesn't work and I > get a syntax error. > > I can't seem to find anything in the help files that explains it.> plot(1:10) > text(8,5,expression(D[obs]^"*")) works for me... Barry
Guenther, Cameron wrote:> Hi all, > I have a question about expression. > > In a figure I want to include the term D*obs with the star as as > superscript and obs as subscript. I have even just tried to get the > star to be superscript. > > > The code I tried was > text(Dstar+7,120,expression(paste({}D,^*))), but that doesn't work and I > get a syntax error. > > I can't seem to find anything in the help files that explains it. >Well, ?plotmath does say A mathematical expression must obey the normal rules of syntax for any R expression, but it is interpreted according to very different rules than for normal R expressions. which should at least explain why you get a syntax error from the above code. Beyond that, you do need to understand how R's syntax rules work, including at least a feel for how expressions are represented internally, and how that influences the plotting of expressions. The easiest solution is probably expression(D^"*")