[R] Expression

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Nov 30 19:10:39 CET 2006


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^"*")



More information about the R-help mailing list