tomcai tomcai - 1 year ago 87
R Question

when use rstudio make r package, the package cant output chinese words,why?

I try to use rstudio to make r package. but the package cant print the right words.

below is the code in package:

hello3 <- function(){

but when use the package ,the output is :

> library(hr)
> hello3()
[1] "娴嬭瘯"

It's evident that the output text into other encodings.

What reason is this?

How to solve this problem?

Answer Source

Using multi-byte characters in your source code makes a lot of headache. I would use unicode expression as below.

hello3 <- function() 


[1] "测试"

If you do not know what is the right expression for your words, try:

sprintf("%x", utf8ToInt("测试"))
[1] "6d4b" "8bd5"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download