[R] German umlaut in xlab

Henrik Bengtsson hb at maths.lth.se
Sun Apr 7 19:14:00 CEST 2002


I have the same problem on WinMe and R v1.4.1 with Swedish keyboard
settings:

  plot(1:10, xlab="äöü")

works in Rgui but not in Rterm under Cygwin bash where it instead prints
"quote down", "qoute up" and a "open box". However,

  plot(1:10, xlab="\344\366\374")

does the same thing. Trying

  print("\344\366\374")

"äöü" will not be shown. Again, with Rgui it works. So there seems to be
some differences in the character encoding etc for the upper ASCII half. I
noticed that when I changed my keyboard settings from Swedish to English the
plot call above works (but not the print call which I believe is due to my
Cygwin/bash settings).

To Petra Steiner: Use the following function to identify your wanted
characters and its ASCII integer code:

plotSymbols <- function() {
  i <- 0:255;
  ncol <-16;
  opar <- par(cex.axis=0.7, mar=c(3,3,3,3)+0.1)
  plot(i%%ncol, 1+i%/%ncol, pch=i, xlab="", ylab="", axes=FALSE)
  axis(1, at=0:15)
  axis(2, at=1:16, labels=0:15*16, las=2)
  axis(3, at=0:15)
  axis(4, at=1:16, labels=0:15*16+15, las=2)
  par(opar)
}

and then use

intToHex <- function(x) {
  x <- as.integer(x)
  class(x) <- "octmode"
  as.character(x)
}

to transform this integer to an octal numbers. For instance, your are
looking for "ü" and from the plot you'll find that its ASCII value is 252,
which gives intToHex(252) equal to "\374" which is what you want to use in
your 'xlab' argument.

FYI: The plotSymbols() function generates the same results under Rgui and
Rterm and with any device driver.

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
Office: P316, +46 46 222 9611 (phone), +46 46 222 4623 (fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/bioinformatics/


> -----Original Message-----
> From: owner-r-help at stat.math.ethz.ch
> [mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Uwe Ligges
> Sent: Sunday, April 07, 2002 4:37 PM
> To: Petra Steiner
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] German umlaut in xlab
>
>
> Petra Steiner wrote:
> >
> > Dear all,
> >
> > which font do I have to choose to use German umlauts at x/ylab
> in plot? Do I
> > have to change Rdevga; and how? Or should I use these Hershey vectors?
> >
> > I looked quite a long time for a solution, which should be easy, so I
> > thought I'd better ask here.
> > Maybe some other people have already solved this problem.
>
> plot(1:10, xlab="äöü") works for me (R-1.4.1 on WinNT4 and Linux) on
> windows() and postscript() device.
> In which case (and OS) does the problem appear?
>
>
> Uwe Ligges
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-.-.-.-.-
> r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list