[英]Cannot load package in R
從昨天開始,我無法通過庫命令加載一些常用的包,例如reshape2
和stringr
。
重現我的問題的步驟:
1)在Rstudio服務器(版本0.99.467)中啟動新會話。 我也殺了Rstudio服務器中的活動會話。
2)運行這些代碼
library(ggplot2)
library(stringr)
3)收到錯誤消息:
unloadNamespace(package)出錯:命名空間'stringr'由'reshape2'導入,因此無法卸載Show Traceback
重新運行調試
庫中的錯誤(stringr):無法卸載“stringr”版本0.6.2。
但是,如果我沒有得到錯誤stringr
之前加載ggplot2
。 我該如何解決這個問題。 謝謝你的任何建議。
我可能需要將R更新為3.2
我的R會話信息:
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
我通過更新R和所有R包解決了我的問題。
我想問題是由舊版本的stringr或reshape2引起的,因為我在不同的地方(系統文件夾或個人庫)安裝相同的軟件包。 R試圖加載舊版本的包。
盡管為我更新R是一個好習慣,但沒有必要解決同樣的問題。 幾個.libPaths()
可能導致問題。 使用.libPaths("C:/Program Files/R/R-3.4.3patched/library")
您可以指出一個文件夾。 之后只需重新安裝包,它應該工作。 我的代碼:
> .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)
即使問題得到解決,我希望它能幫到某個人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.