agatha
agatha

Reputation: 1513

Reading Chinese characters in R

I am using read.xlsx to load a spreadsheet that has several columns containing Chinese characters.

slides<-read.xlsx("test1.xlsx",sheetName="Sheet1",encoding="UTF8",stringsAsFactors=FALSE)

I have tried with and without specifying encoding, I have tried reading from a text file, CSV file etc. No matter the approach, the result is always:

                  樊志强 ->  é‡åº†æ–°æ¡¥åŒ»é™¢ 

Is there any package/format/sys.locale setup that might help me get the right information into R?

Any help would be greatly appreciated.

Upvotes: 1

Views: 3136

Answers (1)

Chengbin Wang
Chengbin Wang

Reputation: 31

You can try the readr package, and use the following code:

library(readr)
loc <- locale(encoding = "UTF-8")
slides <-  read_table("filename", locale = loc)

Upvotes: 1

Related Questions