[R] Title with substitute and paste

Roger D. Peng rpeng at jhsph.edu
Mon Aug 2 22:13:39 CEST 2004


Try, wrapping your substitutes()'s with an eval(), as in

title(eval(substitute(paste("n = ", n), list(n = nval))))

-roger

Wolfgang Viechtbauer wrote:
> Hello All,
> 
> I am generating some plots where the title is generated with substitute
> and paste. An example:
> 
> nval <- 20
> plot(0,0)
> title(substitute(paste("n = ", n), list(n = nval)))
> 
> But when compared to:
> 
> plot(0,0)
> title("n = 20")
> 
> the title in the first plot looks slightly different (it is not in
> bold). How can I get the two titles to look exactly the same?
> 
> Also, how can I generate the following plot:
> 
> plot(0,0)
> title("Test\n n = 20")
> 
> with substitute and paste? I tried:
> 
> nval <- 20
> plot(0,0)
> title(substitute(paste("Test\n", "n = ", n), list(n = nval)))
> 
> but that doesn't produce the same result.
> 
> Thanks in advance for any suggestions!
>




More information about the R-help mailing list