简体   繁体   English

在install.packages()中自动输入

[英]automate input in install.packages()

I am trying to install package 'gpuR' on R.3.4 on PC. 我试图在PC上的R.3.4上安装软件包'gpuR'。 The problem is, when I type install.packages('gpuR') and hit ENTER, the prompt will jump out 问题是,当我键入install.packages('gpuR')并按Enter键时,提示符将跳出

Package which is only available in source form, and may need compilation of C/C++/Fortran: 'gpuR' Do you want to attempt to install these from sources? 只能以源代码形式提供的软件包,可能需要编译C / C ++ / Fortran:'gpuR'您是否想尝试从源代码安装这些软件包?

is there anyway I can automate the input "y" to this prompt? 无论如何我可以自动输入“y”到这个提示?

Perhaps you could use a method that checks for a binary first, and then installs by source if unavailable. 也许您可以使用首先检查二进制文件的方法,然后在不可用时按源安装。 I haven't tested it, but something along the lines of 我没有测试它,但有些东西沿袭了

install.packages.noprompt <- function (pkgs) {
    binPkgs <- available.packages(type = "binary")
    haveBinary <- pkgs %in% binPkgs
    if (any(haveBinary)) {
        install.packages(pkgs[haveBinary], type = "binary")
    }
    if (!all(haveBinary)) {
        install.packages(pkgs[!haveBinary], type = "source")
    }
}

Unfortunately, this probably won't catch dependencies that are source-only, but the package itself has a binary available. 不幸的是,这可能不会捕获仅源的依赖项,但程序包本身具有二进制可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM