how R print UTF-8 code in data.frames on Windows platform Rstudio

 

Questions


When there are UTF-8 characters in the data frame, it won’t be displayed properly.

For example, the following is correct:

> "U6731"
[1] "朱"

But when I put that in a data frame and have it printed, here it is:

> data.frame(x="U6731")
         x
1 <U+6731>

Hence I believe this has nothing to do with encoding issues.

Is there any direct way to print instead of <U+6731>.

I have to use Windows in company so using Linux might not be feasible for me.

 

 

————————————————-

Answer

The corpus library has a work-around for this bug. Either do this:

library(corpus)
df <- data.frame(x = "U6731")
print.corpus_frame(df)

Or else do this:

class(df) <- c("corpus_frame", "data.frame")
df

encoding,r,utf-8

[], [], []

Facebook Comments

Post a comment