根据manual , system2
函数的 stdout
参数可以将输出重定向到一个文件。这似乎适用于 unix,但我无法让它在 Windows 上运行。下面的玩具示例没有创建 out.txt
或 err.txt
文件。我尝试将它发送到现有文件,或展开完整文件路径,但没有成功:
setwd(tempdir())
system2("whoami", stdout="out.txt", stderr="err.txt")
file.exists("out.txt")
我是不是做错了什么或者这是 system2
的限制?
最佳答案
我现在非常确信这是 Windows 中 RGui.exe 中的错误。我在这里提交了错误报告:https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15393
关于将 system2 标准输出重定向到 Windows 上的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17638090/