package cannot be unloaded in R: cannot install package

gaelgarcia picture gaelgarcia · Sep 24, 2015 · Viewed 39.8k times · Source

I am trying to install a package in R, but cannot get around the following error.

What is going on? :(

I am running Fedora 20, R 3.2

 biocLite("monocle")
    BioC_mirror: http://bioconductor.org
    Using Bioconductor version 3.0 (BiocInstaller 1.16.5), R version 3.2.0.
    Installing package(s) 'monocle'
    trying URL 'http://bioconductor.org/packages/3.0/bioc/src/contrib/monocle_1.0.0.tar.gz'
    Content type 'application/x-gzip' length 332309 bytes (324 KB)

    downloaded 324 KB

    installing *source* package ‘monocle’ ...
    R
    inst
    preparing package for lazy loading
    Error in unloadNamespace(package) : 

    namespace ‘plyr’ is imported by ‘reshape2’, ‘ggplot2’, ‘scales’ so cannot be unloaded
    Error in library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : 

    Package ‘plyr’ version 1.8.1 cannot be unloaded
    ERROR: lazy loading failed for package ‘monocle’
    removing ‘/home/user/R/x86_64-redhat-linux-gnu-library/3.2/monocle’

Answer

Dhawal Kapil picture Dhawal Kapil · Sep 25, 2015

looks like monocle is trying to unload and install plyr again but it cant because other packages namely ggplot2, scales and reshape2 has dependency on plyr. Please remove these packages using

remove.packages("ggplot2")
remove.packages("reshape2")
remove.packages("scales")

and finally

remove.packages("plyr")

try installing monocle again now.

Monocle does depends on plyr

Depends R (>= 2.7.0), HSMMSingleCell(>= 0.101.5), Biobase, ggplot2 (>= 0.9.3.1), splines, VGAM (>= 0.9-5), igraph (>= 0.7.0), plyr

on monocle homepage http://bioconductor.org/packages/release/bioc/html/monocle.html