Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从R打开文档?_R_Shell_Cmd_Launch - Fatal编程技术网

如何从R打开文档?

如何从R打开文档?,r,shell,cmd,launch,R,Shell,Cmd,Launch,我想从R中打开一个文件 我可以通过以下方式启动软件(graphpad prism): system2("C:/Program Files (x86)/GraphPad/Prism 7/prism.exe") 我希望它能打开我的prism文件,就像我双击它或从cmd运行它一样,但它没有: system2("H:/Graphs/Shell/Templates/NASH4_Standard.pzfx") 我收到消息: 警告消息:正在运行的命令 “H:/Graphs/Shell/Templates/

我想从R中打开一个文件

我可以通过以下方式启动软件(graphpad prism):

system2("C:/Program Files (x86)/GraphPad/Prism 7/prism.exe")
我希望它能打开我的prism文件,就像我双击它或从cmd运行它一样,但它没有:

system2("H:/Graphs/Shell/Templates/NASH4_Standard.pzfx")
我收到消息:

警告消息:正在运行的命令 “H:/Graphs/Shell/Templates/NASH4_Standard.pzfx”的状态为127

我明白这不是一个错误,只是一个警告。我是否无意中在后台“炮击”了文档?我如何确保它弹出窗口

状态127已寻址,但用于启动软件,而不是用它打开文档。

shell.exec(“C:/Program Files(x86)/GraphPad/Prism 7/Prism.exe”)

对你有用吗

ps.和
shell.exec(“MyWorkbook.xls”)
用默认程序打开文件

shell.exec(“C:/program Files(x86)/GraphPad/Prism 7/Prism.exe”)

对你有用吗


ps.和
shell.exec(“my工作簿.xls”)
使用默认程序打开文件在Windows环境中,您需要调用命令行解释器,如CMD prompt或PowerShell。此外,任何带有空格的文件路径都需要在R中字符串文本所需的引号上方加上双引号(对于.exe而不是特定文件)

使用
system()
在一个字符串中发送整个命令:

system('cmd /c "H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"')

# POWER SHELL REQUIRES MORE QUOTE ESCAPING (ONLY ONE PAIR W/O SPACES)
system('powershell & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""')
使用
system2()
使用args参数:

# FILES
system2('cmd', args=c('/c', '"H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"'))
system2('powershell', args=c(' & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""'))

# EXECUTABLES
system2('cmd', args=c('/c', '"C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"'))
system2('powershell', args=c(' & """C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"""'))

在Windows环境中,您需要调用命令行解释器,如CMD prompt或PowerShell。此外,任何带有空格的文件路径都需要在R中字符串文本所需的引号上方加上双引号(对于.exe而不是特定文件)

使用
system()
在一个字符串中发送整个命令:

system('cmd /c "H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"')

# POWER SHELL REQUIRES MORE QUOTE ESCAPING (ONLY ONE PAIR W/O SPACES)
system('powershell & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""')
使用
system2()
使用args参数:

# FILES
system2('cmd', args=c('/c', '"H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"'))
system2('powershell', args=c(' & """H:/Graphs/Shell/Templates/NASH4_Standard.pzfx"""'))

# EXECUTABLES
system2('cmd', args=c('/c', '"C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"'))
system2('powershell', args=c(' & """C:/Program Files (x86)/GraphPad/Prism 7/prism.exe"""'))

默认情况下,
.pzfx
文件是否与
prism.exe
应用程序关联?如果没有,您可能需要将
.pzfx
文件作为参数传递给第一个命令。当我双击
.pzfx
文件时,它将启动
prism.exe
。如果我将
“H:/Graphs/Shell/Templates/NASH4_Standard.pzfx”
复制到cmd,则相同。这是否意味着它是相关联的;
edit(file=“path/to/file.pzfx”,editor=“path/to/prism.exe”)
对您有用吗?这可以,但没有路径。由于我的工作目录已设置为文件所在的文件夹,
edit(file=“NASH4_Standard.pzfx”,editor=“C:/Program Files(x86)/GraphPad/Prism 7/Prism.exe”)
已工作。默认情况下,
.pzfx
文件是否与
Prism.exe
应用程序关联?如果没有,您可能需要将
.pzfx
文件作为参数传递给第一个命令。当我双击
.pzfx
文件时,它将启动
prism.exe
。如果我将
“H:/Graphs/Shell/Templates/NASH4_Standard.pzfx”
复制到cmd,则相同。这是否意味着它是相关联的;
edit(file=“path/to/file.pzfx”,editor=“path/to/prism.exe”)
对您有用吗?这可以,但没有路径。由于我的工作目录已设置为文件所在的文件夹,
edit(file=“NASH4_Standard.pzfx”,editor=“C:/Program Files(x86)/GraphPad/Prism 7/Prism.exe”)
worked。