R脚本和命令行前端 [英] R scripting and command-line front-end
问题描述
我正在编写一个R脚本来在ubuntu的前端运行命令:
I am writing a R script to run the commands in the front-end in ubuntu:
Rscript my_scripts.R my_file.txt output_file
但是,它给了我一个错误,例如错误:"Rscript my_scripts.R"中的意外符号
However, it gave me an error like "Error: unexpected symbol in "Rscript my_scripts.R"
我遇到了这篇文章 R命令行,将文件名传递给参数中的脚本(Windows).我引用答案"As I said in my comment, I would use Rscript instead of R CMD BATCH:"
I came upon this post R command line passing a filename to script in arguments (Windows). and I quote the answers "As I said in my comment, I would use Rscript instead of R CMD BATCH:"
所以我发现为了运行此程序,我必须安装
So I found that in order to run this, I have to install
sudo apt-get install littler
sudo apt-get install littler
根据此帖子在ubuntu上使用Rscript
当我完成安装此软件包时,它仍然显示相同的错误消息.有解决方案吗?
When I finished install this package, it still showed the same error message. Any solutions?
最好
推荐答案
您是否真的从UNIX shell提示符下运行了它?因为我可以通过在R提示符下键入该命令来得到类似该错误的信息:
Are you really running that from the unix shell prompt? Because I can get something like that error by typing that command at the R prompt:
$ R
[startup noises]
> Rscript foo.r
Error: unexpected symbol in "Rscript foo.r"
否则,脚本中的内容也会被破坏.
Otherwise its something in your script that is similarly screwed up.
从Unix命令提示符运行时,一切正常:
When run from the Unix command prompt, all is well:
$ Rscript test.R
[1] 1.414214
其中test.R
就是print(sqrt(2))
这篇关于R脚本和命令行前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!