如何在R中设置unicode语言环境? [英] How to set unicode locale in R?

查看:919
本文介绍了如何在R中设置unicode语言环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UTF-8 .R文件中有一些特殊字符,并且尝试将代码作为文件在R命令行中运行会返回unexpected INCOMPLETE_STRING.

I have some special characters in my UTF-8 .R file and the attempt to run code as a file in the R command line returns unexpected INCOMPLETE_STRING.

同时,代码可以在RStudio或Eclipse中逐行运行.

Meanwhile, the code runs okay line by line, say, in RStudio or Eclipse.

我建议我需要通过Sys.setlocale(locale=)更改语言环境,但是我为UTF-8找到正确的locale参数的所有尝试(包括SO的回答)都给出了OS reports request to set locale to "UTF-8" cannot be honored.我可以设置Sys.setlocale(locale="English")之类的东西,但这无济于事.

I suggest I need to change the locale via Sys.setlocale(locale=), but all my attempts (including SO's answers) to find the right locale parameter for UTF-8 gave OS reports request to set locale to "UTF-8" cannot be honored. I can set up something like Sys.setlocale(locale="English"), but it doesn't help.

如何在Windows上设置"UTF-8"?

How to set up "UTF-8" on Windows?

推荐答案

我认为您无需将R的语言环境更改为UTF-8(

I don't think you need to change to locale of your R to UTF-8 (if that is even possible under windows)

source(..., locale="UTF-8")

应该可以解决问题.然后将R脚本翻译成您的本地语言环境.

should do the trick. The R-script is then translated into your local locale.

这篇关于如何在R中设置unicode语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆