R/sudo-install.R

Defines functions sudo_install

sudo_install <- function(pkgs) {
    ## pkgs_str <- paste0('"', pkgs, '"') %>%
    ##     paste(collapse=',') %>%
    ##     paste("c(", ., ")")
    ## rcmd0 <- 'options(repos = c(CRAN = "https://mirrors.e-ducation.cn/CRAN/"));'

    os <- Sys.info()[1]
    if (os == "Windows") {
        sudo <- ""
    } else {
        sudo <- "sudo"
    }

    for (pkg in pkgs) {
        pkg <- paste0('"', pkg, '"')
        rcmd <- paste0('install.packages(', pkg, ')')
        ## rcmd <- paste0(rcmd0, rcmd)
        cmd <- paste0(sudo, " Rscript -e '", rcmd, "'")
        system(cmd)
    }
}

Try the yulab.utils package in your browser

Any scripts or data that you put into this service are public.

yulab.utils documentation built on Sept. 20, 2023, 9:06 a.m.