7

Since yesterday, I cannot load some common used packages, e.g. reshape2 and stringr through library command.

Step to reproduce my problem:

1) Start a new session in Rstudio server (Version 0.99.467). I also kill the active-sessions in Rstudio server.

2) Run these codes

library(ggplot2)
library(stringr)

3) Get an error message:

Error in unloadNamespace(package) : namespace ‘stringr’ is imported by ‘reshape2’ so cannot be unloaded Show Traceback

Rerun with Debug

Error in library(stringr) : “stringr” version 0.6.2 cannot be unloaded.

But I don't get error if stringr is loaded before ggplot2. How should I fix this problem. Thanks for any suggestions.

I may have to update R to 3.2

My R session info:

R version 3.1.3 (2015-03-09)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C               LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8    LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_1.0.0

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.4     grid_3.1.3       gtable_0.1.2     MASS_7.3-39      munsell_0.4.2    plyr_1.8.1      
 [8] proto_0.3-10     Rcpp_0.11.2      reshape2_1.4     scales_0.2.4     stringr_0.6.2    tools_3.1.3    
Shawn Mehan
  • 4,513
  • 9
  • 31
  • 51
Bangyou
  • 9,462
  • 16
  • 62
  • 94
  • 2
    You you getting these messages in a fresh R session? Seems odd that the error comes from "unloadNamespace" when you are trying to load the namespace. Are you sure they aren't already loaded before you run this? Are there other commands you are running before this? – MrFlick Nov 05 '15 at 22:49
  • I have narrow down my problem and will edit my question. – Bangyou Nov 05 '15 at 23:23
  • why “stringr” version 0.6.2 when version 1.0.0 is available on cran – MLavoie Nov 06 '15 at 00:21
  • I think I have solve my problem through updating to 3.2 and reinstall all packages. – Bangyou Nov 06 '15 at 00:34
  • You should post that as a solution and mark it as correct, might help others someday. – Mike Wise Nov 06 '15 at 12:21

2 Answers2

4

I resolved my problem through updating R and all R packages.

I guess the problem is caused by old version of stringr or reshape2 as I install the same packages in different places (system folder or personal library). R tried to load a old version of package.

Bangyou
  • 9,462
  • 16
  • 62
  • 94
0

Even though it is a good practice to update R for me it was not necessary to solve the same issue. The problem can result from few .libPaths(). With .libPaths("C:/Program Files/R/R-3.4.3patched/library") you can point out one folder. After that just reinstall of packages, and it should work. My code:

> .libPaths()

[1] "L:/My Documents/R/win-library/3.4"         "C:/Program Files/R/R-3.4.3patched/library"

> .libPaths("C:/Program Files/R/R-3.4.3patched/library")

> packages<-c('ggplot2','data.table','knitr','xtable')

> install.packages(packages)
> lapply(packages,library,character.only=T)

Even though the issue is solved I hope it will help someone.

m.ziembinski
  • 144
  • 5