[R] blank space escape sequence in R?

Petr Savicky savicky at praha1.ff.cuni.cz
Mon Apr 25 19:55:38 CEST 2011


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.



More information about the R-help mailing list