[R] Double expressions in plot labels
David Winsemius
dwinsemius at comcast.net
Mon Jan 23 05:20:08 CET 2012
On Jan 22, 2012, at 10:39 PM, Marcin Kozak wrote:
> Hi all,
>
> I wanted to do something of this sort:
>
> library(lattice)
> label <- expression(alpha)
> xx <- substitute(expression(lab %+-% type), list(lab = label, type =
> " type"))
> stripplot(Species ~ jitter(Petal.Length), iris, ylab = xx,
> horizontal=T)
Try instead:
label <- quote(alpha)
xx <- substitute(expression(lab %+-% type), list(lab = label, type = "
type"))
stripplot(Species ~ jitter(Petal.Length), iris, ylab = xx, horizontal=T)
When you nest an expression call inside an expression things do not go
well.
And quote(alpha) is not the same as "alpha".
>
> (The example plot itself does not make much sense, but I need only to
> construct the label.) Since I want to make it a general function, I
> need to have both these expressions (the "lab" and "type" arguments
> sometimes are and other times are not expressions, but I must assume
> such a possibility). Unfortunately, the above code does not work, that
> is, does not produce a label that should say "alpha +- type" [alpha in
> Greek]. The first part (the alpha) is ignored at all. Any idea how to
> do that?
>
> I work with R 12.1, Windows 7.
>
> Best wishes,
> Marcin
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list