2012-07-24 25 views
0

我尝试使用以下命令来运行的R脚本,[R CMD批问题:意外的输入错误

c:\Progra~1\R\R-2.13.1\bin\R CMD BATCH "test.R" 

文件test.R包含

print ("Hello World") 

不过,我不断收到以下错误。上面的例子很简单,只需要1行就可以使调试更容易。

R version 2.13.1 (2011-07-08) 
Copyright (C) 2011 The R Foundation for Statistical Computing 
ISBN 3-900051-07-0 
Platform: i386-pc-mingw32/i386 (32-bit) 

R is free software and comes with ABSOLUTELY NO WARRANTY. 
You are welcome to redistribute it under certain conditions. 
Type 'license()' or 'licence()' for distribution details. 

Natural language support but running in an English locale 

R is a collaborative project with many contributors. 
Type 'contributors()' for more information and 
'citation()' on how to cite R or R packages in publications. 

Type 'demo()' for some demos, 'help()' for on-line help, or 
'help.start()' for an HTML browser interface to help. 
Type 'q()' to quit R. 

> pError: unexpected input in "print ("Hello World") 
" 
Execution halted 

它工作,如果我添加一个;打印后签名(“Hello World”),但如果test.R中有其他行,则这些行永远不会执行。

能否请您提供建议。

+3

我的猜测是你的编辑器在该行的末尾添加了一个奇怪的字符。 – 2012-07-24 21:02:57

+0

嗨,约书亚,似乎也许是这样。我使用Textpad编辑test.R.一旦我在Unix中创建了该文件并将其复制到Windows,它就没有任何错误。谢谢 ! – xbsd 2012-07-24 21:29:03

+0

@xbsd你可以添加这个作为你的问题的答案吗?通过这种方式,它可以被标记为已回答,并可能对搜索此问题的其他人有所帮助。 – Andrie 2012-07-25 07:54:52

回答

0

我正在使用Textpad编辑test.R.但由于某种原因,它引入了一些我认为不可打印的字符。

一旦我在Unix中创建了test.R,并将其复制到Windows,它没有任何错误。