Rpy2: Korean characters do not work on rpy2

python code:

import rpy2.robjects as robjects

rCommand='''gender <- c("๋‚จ์ž", "๋‚จ์ž", "๋‚จ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž")
  age    <- c(23, 25, 27, 29, 31, 33, 35, 37)
  outdf <- data.frame(gender, age)
'''
robjects.r(rCommand)
resultDf_r=robjects.globalenv["outdf"]

print type(resultDf_r)

Korean characters kill python.exe.

In the R command terminal, "rCommand" above works well.

I could not find a solution.

Any help would be appreciated.

my env: window 7 x64, python 2.7.8 x64, rpy2 2.5.4, R 3.1.2

+4
source share
1 answer

At the time of writing, unfortunately, there is no official support rpy2for windows. The code snippet you provide works fine on Linux.

Your options may be:

  • run your code in a Linux virtual machine (or in a container - MS announced support for Docker)

  • send patch for rpy2

  • rpy2, , -

:. , Python 2.7 ( - Linux, Windows). ( u '''):

rCommand=u'''
    gender <- c("๋‚จ์ž", "๋‚จ์ž", "๋‚จ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž", "์—ฌ์ž")
    age    <- c(23, 25, 27, 29, 31, 33, 35, 37)
    outdf <- data.frame(gender, age)
'''
robjects.r(rCommand)
+4

All Articles