[R] plotting mathematical notation and values substitution

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Apr 4 13:39:41 CEST 2005


Luca Scrucca <luca at stat.unipg.it> writes:

> Dear R-users,
> 
> I'm trying to add a title on a plot with both mathematical notation and
> values substitution. I read the documentation and search the mailing list
> but I was not able to solve my problem. Actually, there is a message by
> Uwe Ligges on June 2003 which addresses a question very close to mine, but
> the code provided doesn't work. The code is the following:
> 
> # I add this to let you run the example by copy and paste
> > t1 <- 0.5; len <- 1
> # then
> > plot(1:10,
>        main = substitute("Monotonic Multigamma run (" * n == len * ", " *
> theta == t1 * ").", list(len = len, t1 = t1)))
> 
> but I got the following:
> 
> Error: syntax error

There's a ")" too many, but more importantly, you have the structure 

A*B==C*D*E==F*G

Since * has higher precedence than ==, this involves associative use
of relational operators (as in 3 < 2 < 1), which is syntactically
forbidden. So you need braces as in

A*{B==C}*D*{E==F}*G

or, maybe easier to read, use:

paste(A, B==C, D, E==F, G}


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list