[R] Math Expression and Variable Value in Title

Henrik Bengtsson hb at maths.lth.se
Thu Jan 29 11:24:44 CET 2004


A quick comment. paste() is not needed here; you can get "=" using
'==' as follows

 substitute(n[i]==k, list=list(k=n))

Cheers

Henrik

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Roger D. Peng
> Sent: den 29 januari 2004 01:35
> To: Wolfgang Viechtbauer
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Math Expression and Variable Value in Title
> 
> 
> Use substitute()
> 
> n <- 20
> plot(0, 0, main = substitute(paste(n[i], " = ", k), list(k = n)))
> 
> -roger
> 
> Wolfgang Viechtbauer wrote:
> 
> > Hello All,
> > 
> > I am trying to put a math expression into a plot title and 
> at the same 
> > time, I want a value in the title to depend on a variable 
> that I set 
> > earlier.
> > 
> > Simple Example:
> > 
> > n <- 20
> > plot(0, 0)
> > title(expression(paste(n[i], " = ", n)))
> > 
> > Obviously, I want "n_i = 20". How can I get that?
> > 
> > Thanks in advance,
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://www.stat.math.ethz.ch/mailma> n/listinfo/r-help
> PLEASE 
> do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list