2012-07-24 28 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,它沒有任何錯誤。