大多数语言都支持双向进程通信.例如,在Python中,我可以(懒散地)做:
>>> from subprocess import *
>>> p = Popen('nslookup', stdin=PIPE, stdout=PIPE)
>>> p_stdin, p_stdout = p.communicate("www.google.com")
>>> print p_stdin
Server: ...
Run Code Online (Sandbox Code Playgroud)
在R中,无论是否用"r +"或"w +"打开我的管道,我似乎只能走一条路.此外,即使我通过R -f ...或运行脚本R < ...,在实际的控制台stdin/stdout中也会出现奇怪的行为.
我的问题可归结为以下内容 - 是否有可能(无需编写C方法!)在R中的上述Python示例中重现双向进程通信?