问题
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)
1 + 2
shell("batchfile.bat", show.output.on.console = FALSE)
Error in system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait, : formal argument "show.output.on.console" matched by multiple actual arguments
system("batchfile.bat", invisible = T)
1 + 2
system("batchfile.bat", show.output.on.console = F)
Warning message: running command 'C:\TEMP\batchfile.bat' had status 1
Is there a way of supressing the console-output on R?
回答1:
options(warn = -1)
shell("You command")
options(warn = 0)
来源:https://stackoverflow.com/questions/45143689/r-supress-console-output-of-a-system-or-shell-command