That's the trick, Eik! Nice job.

To return to the problem I was struggling with, it works with the following
incantation:

names <- c('R', 'P', 'k', 'alpha')
vals <- c(13.34859, 2.53071, 4.06000, 0.00719)
expr <- bquote(.(names[1])==.(vals[1])~",
"~.(as.name(names[2]))[m]==.(vals[2])~",
"
              ~.(as.name(names[3]))[a]==.(vals[3])~", "~.(as.name
(names[4]))[r]==.(vals[4]))
plot(c(0, 1), c(0, 1))
text(0.5, 0.5, expr)

Thanks for the valuable tip!
Dennis

On Tue, Feb 2, 2010 at 2:37 AM, Eik Vettorazzi <
[email protected]> wrote:

> Hi David,
> there is a solution using bquote instead of substitute
>
> expr<-bquote(italic(.(pname[1]))==.(params[1])~", "~.(as.name
> (pname[2]))==.(params[2]))
> plot(1,1,main=expr)
>
> hth.
>
> dkStevens schrieb:
>
>  In trying to create a plotmath expression for plot labeling, such as
>> R = 6, beta = 15
>>
>> where I want beta to be the Greek beta and, possibly, R in italics (like
>> one
>> would get in an explicit expression. The reason for this is that I want to
>> write a string builder function that takes vectors of variable names and
>> their values and return a plotmath expression for labeling a plot. One
>> approach I tried is
>>
>> pname = c("R","beta")
>> params = c(6,15)
>> substitute(p == v,list(p = pname[i],v = format(params[i],digits=4))
>>
>> but this just copies the character strings in pname into the expression.
>> Can
>> anyone help me do what I want? How would I manage passing the resulting
>> string back to the calling routine? Any help will be much appreciated.
>>
>>
>>
>>
>
> --
> Eik Vettorazzi
> Institut für Medizinische Biometrie und Epidemiologie
> Universitätsklinikum Hamburg-Eppendorf
>
> Martinistr. 52
> 20246 Hamburg
>
> T ++49/40/7410-58243
> F ++49/40/7410-57790
>
>
> ______________________________________________
> [email protected] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to