[R] variable values in plotmath expressions
Wolfram Fischer
wolfram at fischer-zim.ch
Fri Sep 3 10:28:39 CEST 2004
Thanks for your help.
On problem is solved now: ``t'' is substituted.
But what to do, if I do not want "x2" as string
but the value of ``x'' as subscript?
I tried the following but it did not help:
t <- "sample text"
x <- 333
..., xlab = substitute(paste(t, 'xlab[', x, ']'), list(t=t, x=x)),
Wolfram
On Fri, 3 Sep 2004, Prof Brian Ripley wrote:
>
> ?substitute, as in
>
> plot(1, 1,
> main = expression(main[x1]),
> xlab = substitute(paste(t, xlab[x2]), list(t=t)),
> sub = parse(text = paste("sub[", x, "]"))
> )
>
> [Why do you think ( needs a space but = does not? There is a canonical
> way to display R code: see `Writing R Extensions' -- please use it.
> Communication is about making life easy for your readers.]
>
> On Fri, 3 Sep 2004, Wolfram Fischer wrote:
>
> > I tried:
> >
> > t <- "sample text"
> > x <- 333
> >
> > plot( 1, 1
> > , main=expression( main[x1] )
> > , xlab=expression( paste( t, xlab[x2] ) )
> > , sub=parse( text = paste( "sub[", x, "]" ) )
> > )
> >
> > The displayed labels for ``main'' and ``sub'' are as expected.
> > But ``xlab'' shows only "t" not "sample text".
> > How can I insert the string on which ``t'' points?
> >
> > I tried e.g.:
> > , ylab=parse( text = paste( t, "ylab[", x, "]" ) )
> > but I received an error (as suspected).
>
> --
> 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