Using chinese characters without changing locale in R

155 views Asked by At

I can use chinese characters in R, can put them in the strings inside a data.frame, substitute them with gsub, and they display normally on screen. I can save them to a file using write.table, but I can't read them with read.table! I'm using fileEncoding="UTF-8" for write.table and for read.table, but the latter gives me:

invalid multibyte string at ...

I've read about changing the locale, but if the chinese characters work everywhere else, I would like not to mess with the locale (my machine use a mix of english and portuguese locale). Is that possible?

I'm using RKWard in Ubuntu 14.10.

EDIT: chinese characters work perfectly everywhere in the files, they just produce errors when used for quoting...

1

There are 1 answers

0
Baptista Zunguze On

Sorry. I arrived too late. I am using ubuntu 20.04 and the following worked for my file:

lists <- read_delim("LISTS.csv", ";", escape_double = FALSE, locale = locale(encoding = "ISO-8859-1"), trim_ws = TRUE)

Good luck