我有一个名为GPOPSIM_for_linux的外部程序,我想从R中运行它,该程序希望以参数文件的名称形式输入用户。假设MyParam.txt是它的名称。
在shell中发出printf 'MyParam.txt' | /home/domi89/GPOPSIM/GPOPSIM_for_linux很好,但是当我尝试
> cmd <- "printf 'MyParam.txt' | /home/domi89/GPOPSIM/GPOPSIM_for_linux"
> system2(command = shQuote(cmd))
sh: 1: "printf 'MyParam.txt' | /home/domi89/GPOPSIM/GPOPSIM_for_linux": not found它不起作用。
发布于 2015-05-21 12:08:49
我把工作目录搞砸了.而且,正如帕夫库西所暗示的,我需要使用system()而不是system2()
现在起作用了:system("cd ./data; printf 'MyParam.txt' | /home/domi89/GPOPSIM/GPOPSIM_for_linux")
发布于 2015-05-21 11:49:40
我怀疑system2的问题在于它需要将命令和参数分开。而对于原始的system函数,您可以使用
system('ls -al')使用system2语法是
system2('ls', args = '-al')https://stackoverflow.com/questions/30370670
复制相似问题