This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to avoid if R packages are installed but not loaded ??

Dear folks,

I am wondering how to stop my further script if required packages are not loaded properly? Somehow packages are installed but while loading its failed and gives error. However, my script run further but its fail when he found function of that unloaded package. I felt, because of dependencies of that packages not installed properly.

My function to install pkgs:

# load multiple packages by once but first to check if installed?
pkgs= c("A", "B","C","D")

# Install packages if not already installed
inst_bio <- pkgs %in% installed.packages()

if(length(pkgs[!inst_bio]) > 0)
{
 source("http://bioconductor.org/biocLite.R") ## online use
 suppressWarnings(suppressMessages(lapply(pkgs[!inst_bio], biocLite, dependencies = T,suppressUpdates=T,ask=F,suppressAutoUpdate=T)))
}

## Load packages into session
suppressWarnings(suppressMessages(lapply(pkgs, require, character.only=T)))

Error : object ålatticeGrobå is not exported by 'namespace:gridExtra'
[[1]]
[1] TRUE

[[2]]
[1] TRUE

[[3]]
[1] FALSE

[[4]]
[1] TRUE

Then I tried manually to install latticeGrob

Warning message:

package ålatticeGrobå is not available (for R version 3.1.3)

So, my question is, how to stop running script if packages are not loaded properly into session?

Thank you

r bioconductor

I would rather ask the question how to make this work rather than asking how to make it fail early :)
latticeGrob isn't a package but part of the ggbio package. You seem to have some broken dependencies. It could be because some packages haven't been built for your system. First identify the package with the broken dependencies then try a different versions to see if that works.

Thank you but I need this solution. what I asked. its my pipeline script.

  1. by the way I try to install ggbio package but its also failed while installing.
  2. I identified that package and tried to install but its depend on another package "RcppArmadillo" and asked to update, I did. but while updating "RcppArmadillo" it failed too!.

..I don't know how to find old version of bioconductor packages.

Since you seem to have gotten the answer, could you post it here so that folks who have a similar question can learn what you did?

1 answer

Your warning message:

package ålatticeGrobå is not available (for R version 3.1.3)

looks like you have some weird characters around the package name. Did you copy & paste the command from somewhere? If not, what is the exact command with which you wanted to install the package?

but you tried to install it like:

install.packages('latticeGrob') ?

Log in to answer this question.