R 系统()命令错误

R system() command error

system("C:\pocketsphinx_continuous -infile C:\temp_speech.wav > c:\capture.txt")

结果进入错误

ERROR: "cmd_ln.c", line 604: Unknown argument name '>'

但是,如果我直接将代码粘贴到 cmd 中,一切正常。提前致谢。 我正在使用 windows8 64 位和 R v 3.2.1.

这是因为 C:\pocketsphinx_continuous 之后的所有内容都被解释为参数。您的命令不是 cmd 中的 运行。请参阅 system:

的帮助页面

command is parsed as a command plus arguments separated by spaces.

...

The most important difference is that on a Unix-alike system launches a shell which then runs command. On Windows the command is run directly – use shell for an interface which runs command via a shell (by default the Windows shell cmd.exe, which has many differences from a POSIX shell).

所以,使用 shell