本文介绍了R 抑制系统或 shell 命令的控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个 windows-batchfile,我使用 shell()
命令从 R 调用它.该批处理文件进行一些计算并将它们写入磁盘和屏幕.我只对磁盘输出感兴趣.我无法更改批处理文件.
批处理文件可能有点像:
@echo off回声 1 + 2@echo 1 + 2 >C:\TEMP\batchoutput.txt出口
我试过了
shell("batchfile.bat", invisible = TRUE)
1 + 2
shell("batchfile.bat", show.output.on.console = FALSE)
系统错误(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait, :形参 "show.output.on.console" 匹配多个实参
system("batchfile.bat", invisible = T)
1 + 2
system("batchfile.bat", show.output.on.console = F)
警告信息:运行命令 'C:\TEMP\batchfile.bat' 的状态为 1
有没有办法抑制 R 上的控制台输出?
解决方案
options(warn = -1)shell("你命令")选项(警告 = 0)
I have this windows-batchfile which I'm calling from R using the shell()
command. This batchfile does some calculations and writes them on the disk but also on the screen. I'm interested in the disk-output, only. I cannot change the batchfile.
The batchfile might be something silly like:
@echo off
echo 1 + 2
@echo 1 + 2 > C:\TEMP\batchoutput.txt
exit
I tried
shell("batchfile.bat", invisible = TRUE)
shell("batchfile.bat", show.output.on.console = FALSE)
system("batchfile.bat", invisible = T)
system("batchfile.bat", show.output.on.console = F)
Is there a way of supressing the console-output on R?
解决方案
options(warn = -1)
shell("You command")
options(warn = 0)
这篇关于R 抑制系统或 shell 命令的控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!