在Linux上如何读取rstudio中文 [英] How to read chinese in rstudio on Linux
问题描述
如下所示的错误。
dt< - read.csv(file =/home/..../aa-0912.csv,header = T,sep =,)
make.names(col.names,unique = TRUE)中的错误:
'< be>< ba>< b5>< c3>< c8>中的无效多字节字符串< cb>'
这个csv文件是由rstudio在Window系统上编写的,如下:
write.csv(file =/home/.../aa-0912.csv,数据)
我可以在窗口中正确读取,但是当我在Linux系统上复制该文件时,read.csv
不起作用。
Linux上的区域设置为:
Sys.getlocale()
[1]LC_CTYPE = en_US.UTF-8; LC_NUMERIC = C; LC_TIME = en_US.UTF-8; LC_COLLATE = en_US.UTF-8; LC_MONETARY =的en_US.UTF-8; LC_MESSAGES =的en_US.UTF-8; LC_PAPER =的en_US.UTF-8; LC_NAME = C; LC_ADDRESS = C; LC_T ELEPHONE = C; LC_MEASUREMENT = en_US.UTF-8; LC_IDENTIFICATION = C
窗口上的语言环境为:
LC_COLLATE = English_United States.1252; LC_CTYPE = English_United States.1252; LC_MONETARY = English_United States.1252; LC_NUMERIC = C; LC_TIME = English_United States.1252
我正在尝试读取数据通过encoding =utf-8,但我收到类似的错误消息。
任何帮助?
我不知道这是你的问题的答案。
我会尽可能的一般,以任何语言出现问题的人都可能有解决方案:
首先在终端 local -a
本地将显示所有系统上可用的区域设置。
一旦您在RStudio上找到了正确的区域设置,就可以使用:
Sys.setlocale(LC_ALL,fr_FR.utf8)
对不起我似乎在我的系统上有任何中文语言环境。其他人也遇到了同样的问题: here 和 here
还看看在?Sys.setlocale
在R。
I encountered an issue when read the chinese file on Linux system by rstudio.
The error as below.
dt <- read.csv(file = "/home/..../aa-0912.csv", header = T , sep=",")
Error in make.names(col.names, unique = TRUE) :
invalid multibyte string at '<be><ba><b5><c3><c8><cb>'
This csv file is written by rstudio on Window system w/o specified encoding, as below:
write.csv(file = "/home/.../aa-0912.csv", data)
And I can read correctly on window but when I copy this file on my Linux system the read.csv doesn't work.
The locale on Linux is :
Sys.getlocale()
[1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C"
The locale on Window is :
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
I am trying to read data by encoding="utf-8" but I got the similar error message.
Any help?
I'm not sure that this is the answer to your question.
I'll try to be as general as possible so that people having trouble in any language might have a solution:
First in the terminal local -a
local would display all the available locales on your system.
Once you found the locale the right locale then on RStudio:
Sys.setlocale("LC_ALL","fr_FR.utf8")
Sorry I don't seem to have any Chinese locale on my system. Other people have had the same issues: here and here
have also a look at ?Sys.setlocale
in R.
这篇关于在Linux上如何读取rstudio中文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!