[R] special character encoding problem

Duncan Murdoch murdoch.duncan at gmail.com
Sun Mar 31 15:31:21 CEST 2013


On 13-03-30 5:07 PM, Huidong TIAN wrote:
> Hi,
>    I have a question about special character: when I  create a data
> frame including some special characters, like 'ø', it displayed as
> '<U+00F8>'. I understand that it's one encoding code for  'ø'. but I
> want to display the letter as  'ø' on my screen. And more, when I save
> the data frame to a local position, it was also save as the encoding
> code instead of the special characters, anybody give some practical
> tips, I have little knowledge about encoding stuff. My operate system
> is windows 7 Simple Chinese,  I use R 2.15.3 64-bit.

You might be able to display more by using different language settings. 
  The problem is that R doesn't think your system knows how to display 
those characters, so rather than displaying ? or similar, it displays 
the Unicode encoding.

I don't have any experience working with a Chinese locale, so I can't 
give specific advice on how to fix this, but the general advice is to 
use a font which contains the characters you need.  R won't switch fonts 
in the middle of a word to handle special characters.

Showing us the result of sessionInfo() might be informative, but you 
probably also need to tell us which font R is using.  You can see that 
in your Rconsole file, displayed by example(Rconsole).

Duncan Murdoch

>
>
>> x <- data.frame(part = c("målløs", "ny"))
>> head(x)
>                    part
> 1 m<U+00E5>ll<U+00F8>s
> 2                   ny
>> x$part
> [1] målløs ny
> Levels: m<U+00E5>ll<U+00F8>s ny
>
> Thanks!
>
> --
> Huidong Tian, Postdoc
>
> Swedish University of Agricultural Sciences
> Department of Aquatic Resources
> Institute of Marine Research
> Turistgatan 5,
> 45330 Lysekil, Sweden
>
> Phone: +47 40624112
> Email: tienhuitung at gmail.com
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list