简体   繁体   中英

automate input in install.packages()

I am trying to install package 'gpuR' on R.3.4 on PC. The problem is, when I type install.packages('gpuR') and hit ENTER, the prompt will jump out

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?

is there anyway I can automate the input "y" to this prompt?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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