how to display a string containing greek chrs and variables

6 messages Options
Embed this post
Permalink
Jose de las Heras

how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink

I'm trying something that I thought would be pretty simple, but it's  
proving quite frustrating...

I want to display, for instance, the correlation coefficient "rho" in a graph.

I can do something like:

text(x, y, paste("rho =", cor))

where cor would be my previously calculated correlation coefficient,  
and x and y the coordinates.
Obviously that displays "rho", not the greek letter rho.

I can do also this:

text(x, y, paste("\\*r =",cor), vfont = c("sans serif","bold"))

that works, but that doesn't look very "pretty".
What looks good is doing something like:

text(x, y, expression(rho))

But I haven't managed to make it do what I need.

I can get this:
text(x, y, expression(rho == 0.8))

that looks good, but how can I substitute the "0.8" for teh name of a  
numeric variable whose value is 0.8?

I'm going slightly mad... it can't be that hard.

Thanks for any help!

Jose


--
Dr. Jose I. de las Heras                      Email: [hidden email]
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*********************************************
NEW EMAIL from July'09: [hidden email]
*********************************************

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
[hidden email] 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.
baptiste auguie-5

Re: how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink
Hi,

try this,

plot.new()
x=0.8
text(0.5, 0.5, bquote(rho == .(x)))


HTH,

baptiste
2009/11/3  <[hidden email]>:

>
> I'm trying something that I thought would be pretty simple, but it's proving
> quite frustrating...
>
> I want to display, for instance, the correlation coefficient "rho" in a
> graph.
>
> I can do something like:
>
> text(x, y, paste("rho =", cor))
>
> where cor would be my previously calculated correlation coefficient, and x
> and y the coordinates.
> Obviously that displays "rho", not the greek letter rho.
>
> I can do also this:
>
> text(x, y, paste("\\*r =",cor), vfont = c("sans serif","bold"))
>
> that works, but that doesn't look very "pretty".
> What looks good is doing something like:
>
> text(x, y, expression(rho))
>
> But I haven't managed to make it do what I need.
>
> I can get this:
> text(x, y, expression(rho == 0.8))
>
> that looks good, but how can I substitute the "0.8" for teh name of a
> numeric variable whose value is 0.8?
>
> I'm going slightly mad... it can't be that hard.
>
> Thanks for any help!
>
> Jose
>
>
> --
> Dr. Jose I. de las Heras                      Email: [hidden email]
> The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
> Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
> Swann Building, Mayfield Road
> University of Edinburgh
> Edinburgh EH9 3JR
> UK
> *********************************************
> NEW EMAIL from July'09: [hidden email]
> *********************************************
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Jose de las Heras

Re: how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink
Quoting baptiste auguie <[hidden email]>:

> Hi,
>
> try this,
>
> plot.new()
> x=0.8
> text(0.5, 0.5, bquote(rho == .(x)))
>
>
> HTH,
>
> baptiste


Aha!

That does exactly what i wanted! Thanks!

Jose

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
[hidden email] 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.
Peter Ehlers

Re: how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink
[hidden email] wrote:

> Quoting baptiste auguie <[hidden email]>:
>
>> Hi,
>>
>> try this,
>>
>> plot.new()
>> x=0.8
>> text(0.5, 0.5, bquote(rho == .(x)))
>>
>>
>> HTH,
>>
>> baptiste
>
>
> Aha!
>
> That does exactly what i wanted! Thanks!
>
> Jose

But does it do what it should? It's customary to use
"rho" for a _population_ correlation coefficient. If your
(x,y) values represent a _sample_, then it would probably
be more appropriate to use the more mundane "r" or
perhaps "rho-hat".
>

--
Peter Ehlers
University of Calgary

______________________________________________
[hidden email] 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.
Jose de las Heras

Re: how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink
Quoting Peter Ehlers <[hidden email]>:

> [hidden email] wrote:
>> Quoting baptiste auguie <[hidden email]>:
>>
>>> Hi,
>>>
>>> try this,
>>>
>>> plot.new()
>>> x=0.8
>>> text(0.5, 0.5, bquote(rho == .(x)))
>>>
>>>
>>> HTH,
>>>
>>> baptiste
>>
>>
>> Aha!
>>
>> That does exactly what i wanted! Thanks!
>>
>> Jose
>
> But does it do what it should? It's customary to use
> "rho" for a _population_ correlation coefficient. If your
> (x,y) values represent a _sample_, then it would probably
> be more appropriate to use the more mundane "r" or
> perhaps "rho-hat".


I'm talking rank correlation, Spearman's rho.

Jose

--
Dr. Jose I. de las Heras                      Email: [hidden email]
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*********************************************
NEW EMAIL from July'09: [hidden email]
*********************************************

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

______________________________________________
[hidden email] 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.
Peter Ehlers

Re: how to display a string containing greek chrs and variables

Reply Threaded More More options
Print post
Permalink
[hidden email] wrote:

> Quoting Peter Ehlers <[hidden email]>:
>
>> [hidden email] wrote:
>>> Quoting baptiste auguie <[hidden email]>:
>>>
>>>> Hi,
>>>>
>>>> try this,
>>>>
>>>> plot.new()
>>>> x=0.8
>>>> text(0.5, 0.5, bquote(rho == .(x)))
>>>>
>>>>
>>>> HTH,
>>>>
>>>> baptiste
>>>
>>>
>>> Aha!
>>>
>>> That does exactly what i wanted! Thanks!
>>>
>>> Jose
>>
>> But does it do what it should? It's customary to use
>> "rho" for a _population_ correlation coefficient. If your
>> (x,y) values represent a _sample_, then it would probably
>> be more appropriate to use the more mundane "r" or
>> perhaps "rho-hat".
>
>
> I'm talking rank correlation, Spearman's rho.
>
> Jose
>
Rank correlation or not, it's still customary to use "r"
or "r[s]" for samples and rho or rho[s] for populations.
But it's up to you, of course.
--
Peter Ehlers
University of Calgary

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