【发布时间】:2012-07-24 20:54:27
【问题描述】:
我正在尝试使用以下内容运行 R 脚本,
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
如果我添加一个 ; 它会起作用在 print ("Hello World") 后签名,但如果 test.R 中有其他行,则这些行永远不会被执行。
请指教。
【问题讨论】:
-
我的猜测是您的编辑器在该行的末尾放了一个奇怪的字符。
-
嗨 Joshua,似乎是这样。我正在使用 Textpad 编辑 test.R。一旦我在 Unix 中创建文件并复制到 Windows,它就可以正常工作。谢谢!
-
@xbsd 您能否将其添加为您问题的答案?通过这种方式,它可以被标记为已回答,并且可能对搜索此问题的其他人有所帮助。
标签: r