Dear helpers, I am not able to export Unicode characters from R. Below is an example where the Unicode character is correctly rendered as long as I am stay within R. When I export it, the character appears only with its basic code, and the same happens when I import it back into R . I'm using R 2.13.1 in Windows XP.> funny.g <- "\u1E21"> funny.g[1] "?"> data.frame (funny.g) -> funny.g> funny.g$funny.g[1] ? Levels: <U+1E21>> write.table (funny.g, file = "C:/~funny.g.txt", col.names = FALSE, row.names = FALSE, quote = FALSE, fileEncoding = "UTF-8")> read.table ("C:/~funny.g.txt", header = FALSE, encoding = "UTF-8") -> input.funny.g> input.funny.g$V1[1] <U+1E21> Levels: <U+1E21> Best Sverre
On 11-07-14 7:11 PM, Sverre Stausland wrote:>> > funny.g<- "\u1E21" >> > funny.g > [1] "?" > >> > data.frame (funny.g) -> funny.g >> > funny.g$funny.g > [1] ? > 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. 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. Duncan Murdoch> >> > write.table (funny.g, file = "C:/~funny.g.txt", col.names = FALSE, row.names = FALSE, quote = FALSE, fileEncoding = "UTF-8")