Quantcast

Re: Special characters: plus/minus - a method that works

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Special characters: plus/minus - a method that works

Smith, Phil (CDC/CCID/NCIRD)
Dear R-people:
 
François Michonneau's method to obtain the special character plus/minus works on Windows 2000 professional.
 
Many Thanks to François for his work!
 
Phil Smith
Centers for Disease Control and Prevention
Atlanta, GA

  _____  

From: François MICHONNEAU [mailto:[hidden email]]
Sent: Monday, March 20, 2006 1:58 PM
To: [hidden email]; Smith, Phil
Subject: Re: [R] Special characters: plus/minus


Hello,

You can obtain the special character plus/minus by a copy from the MS Windows "Character Table" and paste it in the R console or in your text editor as (NotePad or Emacs). Then, you can use it in your script:
x <- 5
y <- 0.25
paste (x, "±", y)

Cheers

François Michonneau


        [[alternative HTML version deleted]]


______________________________________________
[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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Special characters: plus/minus - a method that works

Gabor Grothendieck
Another way that works on my Windows XP system is
to use "\261" .


On 3/20/06, Smith, Phil <[hidden email]> wrote:

> Dear R-people:
>
> François Michonneau's method to obtain the special character plus/minus works on Windows 2000 professional.
>
> Many Thanks to François for his work!
>
> Phil Smith
> Centers for Disease Control and Prevention
> Atlanta, GA
>
>  _____
>
> From: François MICHONNEAU [mailto:[hidden email]]
> Sent: Monday, March 20, 2006 1:58 PM
> To: [hidden email]; Smith, Phil
> Subject: Re: [R] Special characters: plus/minus
>
>
> Hello,
>
> You can obtain the special character plus/minus by a copy from the MS Windows "Character Table" and paste it in the R console or in your text editor as (NotePad or Emacs). Then, you can use it in your script:
> x <- 5
> y <- 0.25
> paste (x, "±", y)
>
> Cheers
>
> François Michonneau
>
>
>        [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> [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
>
>

______________________________________________
[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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Special characters: plus/minus - a method that works

Peter Alspach
In reply to this post by Smith, Phil (CDC/CCID/NCIRD)

Gabor Grothendieck wrote:

> Another way that works on my Windows XP system is to use "\261" .

Please note Windows escape codes are not portable thus not recommended as Martin Maechler pointed out in a response to a suggestion of mine:

On Tue, 14 Jun 2005, Martin Maechler wrote:


>>>>>> "Peter" == Peter Alspach <PAlspach at hortresearch.co.nz>
>>>>>> on Tue, 14 Jun 2005 14:11:47 +1200 writes:
>
> Peter> Ben
>
> Peter> Others have pointed out plotmath. However, for some
> Peter> superscripts (including 2) it may be easier to use
> Peter> the appropriate escape sequence (at in Windows):
>
> Peter> ylab = 'BA (m\262/ha)'
>
> but please refrain from doing that way.
> You should write R code that is portable, and ``plotmath''
> has been designed to be portable. Windows escape codes are not,
> and may not even work in future (or current?) versions of
> Windows with `unusual' locale settings {fonts, etc}.


Peter Alspach

______________________________________________________

The contents of this e-mail are privileged and/or confidenti...{{dropped}}

______________________________________________
[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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Special characters: plus/minus - a method that works

Martin Maechler
>>>>> "Peter" == Peter Alspach <[hidden email]>
>>>>>     on Tue, 21 Mar 2006 14:35:43 +1200 writes:

    Peter> Gabor Grothendieck wrote:

    >> Another way that works on my Windows XP system is to use "\261" .

    Peter> Please note Windows escape codes are not portable thus not recommended as Martin Maechler pointed out in a response to a suggestion of mine:

    Peter> On Tue, 14 Jun 2005, Martin Maechler wrote:


    >>>>>>> "Peter" == Peter Alspach <PAlspach at hortresearch.co.nz>
    >>>>>>> on Tue, 14 Jun 2005 14:11:47 +1200 writes:
    >>
    Peter> Ben
    >>
    Peter> Others have pointed out plotmath. However, for some
    Peter> superscripts (including 2) it may be easier to use
    Peter> the appropriate escape sequence (at in Windows):
    >>
    Peter> ylab = 'BA (m\262/ha)'
    >>
    >> but please refrain from doing that way.
    >> You should write R code that is portable, and ``plotmath''
    >> has been designed to be portable. Windows escape codes are not,
    >> and may not even work in future (or current?) versions of
    >> Windows with `unusual' locale settings {fonts, etc}.

    Peter> Peter Alspach

Indeed, thank you, Peter.

For the present case,
if you really want something better than the ASCII "+/-" that
Duncan recommended (and I agree),
you can do what I had recommended above:  

use 'plotmath' --> ?plotmath
and see that

the    %+-%   symbol works -- platform independently! --
e.g.,

  plot(1, main = expression(3 %+-% 0.1))

or a bit more realistically:

   m <- pi
  sd <- 1/7
  plot(1, main = substitute(mu %+-% sig, list(mu = m, sig = sd)))
## or
  plot(1, main = substitute(mu %+-% sig,
                            list(mu= round(m,3), sig= round(sd,3))))

--
Martin Maechler, ETH

______________________________________________
[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
Loading...