4

I tried to run a simple command in R, as a script, like this one

print("寛")

And R gives me an error like this:

Error in source(con, echo = echo, print.eval = print.eval, max.deparse.length = max.deparse.length, : con:2:7: unexpected INCOMPLETE_STRING

I guess this is some kind of encoding issue, and that Chinese word is exactly what I need to use in R. What can I do?

lokheart
  • 23,743
  • 39
  • 98
  • 169
  • You should check that the encoding used by your locale (add `sessionInfo()` to your script to see it) and used to save the file are the same, and allow Chinese characters. It works, for instance, with UTF8. – Vincent Zoonekynd Jan 17 '12 at 03:32
  • I tried but the error message pops out as `Warning message: In Sys.setlocale("LC_CTYPE", "UTF-8") : OS reports request to set locale to "UTF-8" cannot be honored` – lokheart Jan 17 '12 at 03:51
  • That is only the encoding half of the locale. The following may work: `Sys.setlocale("LC_CTYPE", "en_GB.UTF-8")`. – Vincent Zoonekynd Jan 17 '12 at 05:09

0 Answers0