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

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sun Oct 11 21:48:02 CEST 2020


You would do better posting this on r-package-devel rather than here, I
believe.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Oct 11, 2020 at 11:51 AM 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]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list