R中带连字符的字符串

时间:2012-11-14 11:22:16

标签: r rstudio

我在R中有一个字符串(使用RStudio)

legend <- c('Up to 5 minutes', '5-10 minutes', '10–20 minutes', '20–40 minutes', '40–80 minutes', '80-160 minutes', '160-320 minutes', '5.3-10.6 hours', '10.6-21.2 hours', '1-2 days')

当我只是逐行运行源代码时运行正常。但是,当我获取代码时,它会抛出错误

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

哪里可能是问题?

1 个答案:

答案 0 :(得分:5)

从RStudio发布的讨论更新:

http://support.rstudio.org/help/discussions/problems/3945-bug-when-sourcing-the-application

相关部分:

  

直到现在我才注意到它,但是在开始R时我得到了

Enabling Justin-In-Time compilation, level 3.
[1] 0
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_COLLATE failed, using "C" 
3: Setting LC_TIME failed, using "C" 
4: Setting LC_MESSAGES failed, using "C" 
5: Setting LC_PAPER failed, using "C" 
[R.app GUI 1.53 (6335) i386-apple-darwin9.8.0]

WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work.
Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly.
  

阅读常见问题解答我做了标准system("defaults write org.R-project.R force.LANG en_US.UTF-8"),现在效果很好。