package cannot be unloaded in R: cannot install package

error in unloadnamespace(package)
unload package r
namespace ‘dplyr’ is imported by ‘plotly’ so cannot be unloaded
package ‘lattice’ version 0.20.38 cannot be unloaded:
namespace ‘knitr’ is imported by ‘rmarkdown’ so cannot be unloaded
package ‘ggplot2’ version 3.1.0 cannot be unloaded:
package ‘dplyr’ version 0.8.3 cannot be unloaded:
package ‘lattice’ version 0.20.35 cannot be unloaded:

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’

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

Conflicting packages - General, Package 'stringr' version 1.3.0 cannot be unloaded: Error in (e.g., an RStudio Server installation); What packages are you loading explicitly  If you're trying to install a newer version of stringr, you need to do that in a fresh session without any packages loaded (other than the base defaults). This might require restarting your Jupyter kernel and making sure you don't run any cells that load packages via library() or require() .

I was getting the same error for MASS package.

Below command used to remove that package.

remove.packages("MASS")

Tried freshly below commands and it worked.

install.packages("MASS")
library(MASS)

Warning about unloading packages / error on installing dplyr and rgl , Warning about unloading packages / error on installing dplyr and rgl #155 Warning message: 'magrittr' namespace cannot be unloaded: namespace The script runs without problems in a clean session of R, but upon  If the package is installed, there is no reason to re-install, and installation should be skipped. The reason is that an MRAN package on a given snapshot date can never change and be updated. The reason is that an MRAN package on a given snapshot date can never change and be updated.

After you uninstall the packages, quit() and restart R again

Package 'stringr' version 1.3.0 cannot be unloaded: Error in , I then install my package and run the ocpu server. unloadNamespace(package​) : namespace 'stringr' is imported by 'evaluate' so cannot be unloaded #297 I'​ve updated the latest containers now with the latest versions of all R packages. The server admin does not want to update the packages on the system library because it may effect other users, so I had to install them all into my user library. For some reason, my user name on the server can not get past my companies proxy, so I am forced to upload the .tar.gz files from CRAN and then install the packages via the command line.

I resolved this by restarting R.

Error message: 'Package 'knitr' version 1.19 cannot be unloaded , version 1.19 cannot be unloaded: ## Error in unloadNamespace(package) both in surveys at the top of blocks that include any R code (see attachment; Unrelated: is there a chance you could install the fmsb package? When working with your own package, you can use devtools::install_local() to install either from a local directory containing source package, or either from a build source packages tar.gz. See the help

R: 'Matrix' can not be unloaded, but 'writeMM' method not found , I installed it, but when I try loading it: Error in value[[3L]](cond) : Package 'Matrix​' version 1.2.11 cannot be unloaded: Error in Ultimately I just restarted Rstudio as Konrad Rudolph suggested, imported Matrix library, and http://www.sthda.​com/english/wiki/saving-data-into-r-data-format-rds-and-rdata. If R (or RStudio with R) was installed as administrator in Windows and you try to install or update a package you lack of permissions. Either run the installation as admin or avoid the installation as admin.

ns-load: Loading and Unloading Name Spaces, Functions to load and unload name spaces. R Documentation. /. base. /. ns-​load: Loading and Now ignored except during package installation. keep.parse​. Support for Parallel computation in R. Support for parallel computation, including by forking (taken from package multicore), by sockets (taken from package snow) and random-number generation.

IRanges, Documentation. To view documentation for the version of this package installed in your system, start R and enter: browseVignettes("IRanges")  @couthcommander-- you are correct! Interesting. Wonder what the conflict was -- but it is now fixed in that Hmisc compiled.. As an aside, in the world of biological sequence data and the need to analyze, bioconductor is a means by which to get that job done and to scale efficiently.

Comments
  • It's trying to unload plyr but you have other packages loaded that are preventing it from doing so - I'm not exactly sure why it's trying to unload plyr, but maybe try unloading reshape2, ggplot2, and scales and see if you can install monocle?
  • Thanks, how can I unload those other packages?
  • as per stackoverflow.com/a/6979989/743568, detach("package:reshape2", unload=TRUE) and so on.
  • Does it help to start R with the option --vanilla, R --vanilla ? Perhaps you have a .Rprofile or .RData file that is causing plyr and other packages to be loaded during installation.
  • I wish that would solve it! I've tried it several times, but still get the same error once I go back and try to install Monocle... even if all the packages are uninstalled.
  • is your package BiocInstaller out dated..because in my RStudio while installing its printing trying URL 'http://bioconductor.org/packages/3.1/bioc/bin/windows/contrib/3.2/monocle_1.2.0.zip' Content type 'application/zip' length 756322 bytes (738 KB) downloaded 738 KB while in your its downloading a previous version of monocle