如何在Windows上使用Sys.which查找正确的可执行文件
有什么办法在
Windows上使它成为Sys.which找到适当的可执行文件?两个重新解决问题的案例:
> convert.exe这是一个Windows程序和ImageMagik程序,但Sys.which只找到一个从来没有想过R的窗口,无论我怎么在我的PATH上安排东西. 所以,每当我在Windows上时,我都会编写一个调用7-zip的包装器.这不可能做的事情可以吗? 编辑 实际上只是将一个环境变量添加到.Renviron:TAR = path / to / tar.exe适用于install.packages示例,我无法记住tar.exe咬我的地方,但Josh回答了主要问题.,convert.exe. 解决方法
我在今年早些时候提出了一个相同的问题
over on R-devel.在回复中,this one由Henrik Bengtsson提供,他们提供了以下有用的功能:
Sys.which2 <- function(cmd) { stopifnot(length(cmd) == 1) if (.Platform$OS.type == "windows") { suppressWarnings({ pathname <- shell(sprintf("where %s 2> NUL",cmd),intern=TRUE)[1] }) if (!is.na(pathname)) return(setNames(pathname,cmd)) } Sys.which(cmd) } ## Trying out Sys.which & Sys.which2 on my Windows box gives the following: Sys.which("convert") # convert # "C:Windowssystem32convert.exe" Sys.which2("convert") # convert # "C:Program FilesImageMagick-6.8.8-Q16convert.exe" 我真的不确定为什么R-core不仅修复Sys.which()以使其实际上是可移植的,但它们至少会在系统中记录这种行为的根本原因(其功能受到同一问题的影响) :
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-ce – 带嵌入式Windows的手持设备7
- [转帖]Windows下cwRsyncServer双机连续同步部署
- Windows应用商店应用 – WinJS:0x800a1391 – J
- Windows上的IP设置
- Buildtool类似于Windows的bitbake
- Windows Server 2016-Hyper-V HNV 新增功能
- Windows命令行:启动/等待wordpad
- windows-server-2003 – 我可以从RAID-1升级到RA
- 用于从远程计算机复制文件的Windows实用程序
- windows-server-2012-r2 – iscsi Windows Serve