我正在尝试使用shell命令从R运行简单的外部应用程序。
shell('"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe" "C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\" "1" "yes"')
如果我从命令行运行部分括号,它可以正常工作。但如果我通过R的shell命令运行它会引发错误:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' had status 1
2: In shell("\"C:\\Program Files\\SomeApp\\bin\\Release\\SomeApp.exe\" \"C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\\" \"1\" \"yes\"") :
'"C:\Program Files\SomeApp\bin\Release\SomeApp.exe" "C:\Users\SomeUser\R_Scripts\RProjects\Rprojects\" "1" "yes"' execution failed with error code 1
其他人是否面临同样的问题?
答案 0 :(得分:2)
空格分隔的文字应该是双引号。这适用于R的shell命令。
shell('C:\\"Program Files"\\SomeApp\\bin\\Release\\SomeApp.exe "C:\\Users\\SomeUser\\R_Scripts\\RProjects\\Rprojects\\" "1" "yes"')