[R] Installing bioconduction packages in connection with loading an R package

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Oct 11 21:01:17 CEST 2020


This sounds like your package belongs in the bioconductor repository rather than in CRAN. Referencing bioc packages only in Suggests might make it appropriate for CRAN.

On October 11, 2020 11:51:29 AM PDT, "Søren Højsgaard" <sorenh using math.aau.dk> wrote:
>Dear all,
>
>My gRbase package imports functionality from the bioconductor packages
>graph, Rgraphviz and RBGL.
>
>To make installation of gRbase easy, I would like to have these
>bioconductor packages installed in connection with installation of
>gRbase, but to do so the user must use setRepositories() to make sure
>that R also installs packages from bioconductor.
>
>Having to call setRepositories causes what can perhaps be called an
>(unnecessary?) obstacle. Therefore I have been experimenting with
>deferring installation of these bioc-packages until gRbase is loaded
>the first time using .onAttach; please see my attempt below.
>
>However, if the bioc-packages are not installed I can not install
>gRbase so that does not seem to be a viable approach. (The
>bioc-packages appear as Imports: in DESCRIPTION).
>
>Can anyone tell if it is a futile approach and / or perhaps suggest a
>solution. (I would guess that there are many CRAN packages that use
>bioc-packages, so other people must have faced this challenge before).
>
>Thanks in advance.
>
>Best regards
>S�ren
>
>
>
>
>
>.onAttach<-function(libname, pkgname) {
>
>    ## package startup check
>    toinstall=c(
>        "graph",
>        "Rgraphviz",
>        "RBGL"
>    )
>
>    already_installed <- sapply(toinstall, function(pkg)
>        requireNamespace(pkg, quietly=TRUE))
>
>    if (any(!already_installed)){
>    packageStartupMessage("Need to install the following package(s): ",
>                         toString(toinstall[!already_installed]), "\n")
>    }
>
>    ## install if needed
>    if(!base::all(already_installed)){
>        if (!requireNamespace("BiocManager", quietly=TRUE))
>            install.packages("BiocManager")
> BiocManager::install(toinstall[!already_installed], dependencies=TRUE)
>    }
>}
>
>
>
>	[[alternative HTML version deleted]]

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list