如何使用 R CMD BATCH 抑制行号输出? [英] How can I suppress the line numbers output using R CMD BATCH?

查看:24
本文介绍了如何使用 R CMD BATCH 抑制行号输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个 R 脚本:

If I have an R script:

print("hi")
commandArgs()

我使用:

r CMD BATCH --slave --no-timing test.r output.txt

输出将包含:

[1] "hi"
[1] "/Library/Frameworks/R.framework/Resources/bin/exec/x86_64/R"
[2] "-f"                                                         
[3] "test.r"                                                     
[4] "--restore"                                                  
[5] "--save"                                                     
[6] "--no-readline"                                              
[7] "--slave"                                                    

如何抑制行号[1]..[7]在输出中所以只出现脚本的输出?

How can i suppress the line numbers[1]..[7] in the output so only the output of the script appears?

推荐答案

是的,mbq 是正确的——使用 Rscript,或者,如果它漂浮在你的船上,littler:

Yes, mbq is right -- use Rscript, or, if it floats your boat, littler:

$ cat /tmp/tommy.r 
#!/usr/bin/r

cat("hello world\n")
print(argv[])
$ /tmp/tommy.r a b c
hello world
[1] "a" "b" "c"
$

您可能想查看 CRAN 包 getoptoptparse 用于参数解析,就像您在其他脚本语言中所做的一样/

You probably want to look at CRAN packages getopt and optparse for argument-parsing as you'd do in other scripting languages/

这篇关于如何使用 R CMD BATCH 抑制行号输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆