[R] Help with plotmath
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jun 10 13:39:47 CEST 2004
You *parse* strings to form expressions.
plot( c(0,1), c(0,1), main=parse(text=ex) )
On Thu, 10 Jun 2004, Steve Roberts wrote:
> There must be a simple answer. I want to plot an expression,
> where the expression is held in a string variable. The "obvious"
> solution along the lines of
>
> ex<-"x^2"
> plot( c(0,1), c(0,1), main=as.expression(ex) )
>
> gives me the a title x^2 - ie doesn't treat it like an expression. I
> suspect I don't understand expressions properly. For the real
> problem I do need to have my expression string in a variable as it is
> data-dependent.
You might also want to explore substitute.
> Can someone tell me the magic words?
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list