how to avoid if R packages are installed but not loaded ??
1
0
Entering edit mode
9.1 years ago

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 • 4.3k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

leave it, its done. I made it by myself.

Thank you by the way

ADD REPLY
1
Entering edit mode

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?

ADD REPLY

Login before adding your answer.

Traffic: 2175 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6