Re: [R] blank space escape sequence in R?

From: Petr Savicky <savicky_at_praha1.ff.cuni.cz>
Date: Mon, 25 Apr 2011 19:55:38 +0200

On Mon, Apr 25, 2011 at 04:37:15PM +0200, Jan van der Laan wrote:
> There exists a non-breaking space:
>
> http://en.wikipedia.org/wiki/Non-breaking_space
>
> Perhaps you could use this. In R on Linux under gnome-terminal I can
> enter it with CTRL+SHIFT+U00A0. This seems to work: it prints as a
> space, but is not equal to ' '.

This character may be specified as "\u00A0".

  a <- "abc\u00A0def"
  a
  [1] "abc def"   

The utf-8 representation of the obtained string is

  charToRaw(a)
  [1] 61 62 63 c2 a0 64 65 66

Using Unicode package, the string may be analyzed as follows

  library(Unicode)
  u_char_inspect(as.u_char_seq(a, ""))

      Code                 Name Char
  1 U+0061 LATIN SMALL LETTER A    a
  2 U+0062 LATIN SMALL LETTER B    b
  3 U+0063 LATIN SMALL LETTER C    c
  4 U+00A0       NO-BREAK SPACE     
  5 U+0064 LATIN SMALL LETTER D    d

  6 U+0065 LATIN SMALL LETTER E e
  7 U+0066 LATIN SMALL LETTER F f

Hope this helps.

Petr Savicky.



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. Received on Mon 25 Apr 2011 - 17:57:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Apr 2011 - 18:10:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive