R 使用系统命令打开具有特定路径的windows资源管理器

R 使用系统命令打开具有特定路径的windows资源管理器,r,system,R,System,我发现可以使用以下命令通过cmd.exe程序以预定义路径打开windows资源管理器: explorer PATH 使用以下命令返回R打开windows资源管理器: system("explorer", intern=TRUE) 但是,当我指定路径时,R将返回以下警告消息,并且不会在指定路径处打开资源管理器: > system("explorer C:\\Users\\xxx", intern=TRUE) character(0) attr(,"status") [1] 1

我发现可以使用以下命令通过cmd.exe程序以预定义路径打开windows资源管理器:

explorer PATH 
使用以下命令返回R打开windows资源管理器:

system("explorer", intern=TRUE) 
但是,当我指定路径时,R将返回以下警告消息,并且不会在指定路径处打开资源管理器:

> system("explorer C:\\Users\\xxx", intern=TRUE) 
character(0) 
attr(,"status") 
[1] 1 
Warning message: 
running command 'explorer C:\Users\xxx' had status 1 
我引用了\R抱怨没有从用户中识别出\U

但是,当按照我们预期的方式执行命令时,double\仅被一个替换

当我将浏览器C:\Users\xxx位从R警告消息复制粘贴到cmd.exe程序时,浏览器将在指定路径打开

有人知道为什么会失败吗

试试看

shell("explorer C:\\Users\\xxx", intern=TRUE) 

我已经创建了这个简单的函数。。。我希望它会有用

wopen <- function(x){
  y <- getwd()
  y <- gsub("/", "\\\\", y)
  shell(paste0("explorer ", y), intern = TRUE) 
}

wopen你好!成功了。谢谢!我刚刚将mac os R更新为2.15.0,但似乎没有适用于mac版本的shell命令…在MacOS下,您可以使用system(“open/Applications/”)等