[R] Export Unicode characters from R
murdoch.duncan at gmail.com
Fri Jul 15 19:56:29 CEST 2011
On 15/07/2011 1:42 PM, Sverre Stausland wrote:
> >>> > funny.g<- "\u1E21"
> >>> > funny.g
> >>  "ḡ"
> >>> > data.frame (funny.g) -> funny.g
> >>> > funny.g$funny.g
> >>  ḡ
> >> Levels:<U+1E21>
> > I think the problem is in the data.frame code, not in writing. Data.frames
> > try to display things in a readable way, and since you're on Windows where
> > UTF-8 is not really supported, the code helpfully changes that character to
> > the "<U+1E21>" string. for display.
> I thought the data.frame function didn't alter the unicode coding,
> since funny.g$funny.g above still displays the right unicode character
> (although it does list the levels as<U+1E21>).
> > You should be able to write the Unicode character to file if you use lower
> > level methods such as cat(), on a connection opened using the file()
> > function with the encoding set explicitly.
> I'm sorry, but I don't understand what it means "to use cat() on a
> connection opened using the file() function". Could you please clarify
Sorry, I think my suggestion was wrong. What I meant was something like
file <- file("your filename", encoding="UTF-8")
cat("\u1E21", file= file)
but this doesn't appear to work.
More information about the R-help