我已经尝试过 Rscript 和 R CMD BATCH。
例如,如果我运行这个简单的 R 脚本:
test <- function(){
print("test")
}
通过使用
> R CMD BATCH test.R
我得到以下 test.Rout 文件:
R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-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.
[Previously saved workspace restored]
> test <- function(){
+ print("test")
+ }
>
> proc.time()
user system elapsed
0.176 0.016 0.186
我没有看到预期的输出:
>[1] "test"
任何地方 - 在命令行或 test.Rout 文件中。
使用 Rscript 我在命令行上也看不到任何输出。
如果我在 RStudio 中运行它,我有一个很长的 R 脚本,它会在特定目录下写入一个报告文件。但是,当我使用 R CMD BATCH 运行此脚本时,我看不到目录中生成的文件。在相应的 .Rout 文件中,我看到代码各行的类似运行语句 - 而不是执行结果。
我正在使用 Ubuntu 12.04 LTS。
我究竟做错了什么?
谢谢!