【问题标题】:Namespace load failed for ggplot2, DESCRIPTION failed for gridggplot2 的命名空间加载失败,网格的描述失败
【发布时间】:2016-10-16 03:32:12
【问题描述】:

我最近删除了几个 R 包(使用 remove.packages()),并重新安装了它们的最新版本。我尝试使用以下语法重新安装库网格:

url <- "https://cran.r-project.org/src/contrib/Archive/grid/grid_0.7-4.tar.gz"
pkgFile <- "grid_0.7-4.tar.gz"
download.file(url = url, destfile = pkgFile)
install.packages(pkgs=pkgFile, type="source", repos=NULL)
unlink(pkgFile)

我收到以下警告和错误:

Error : Invalid DESCRIPTION file

Invalid package name.
This is the name of a base package.

See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.

ERROR: installing package DESCRIPTION failed for package ‘grid’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/grid’
Warning in install.packages :
  installation of package ‘/Users/lindz/RNASeqVisualization/grid_0.7-4.tar.gz’ had non-zero exit status

网格现在似乎是基础 R 的一部分,所以我暂时继续前进。但是,在重新安装包 ggplot2 时,使用:

install.packages("ggplot2")

我收到以下警告:

Warning in install.packages :
  URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': status was '400 Bad Request'

Warning in install.packages :
  URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': status was '400 Bad Request'
Warning in install.packages :
  unable to access index for repository https://R-Forge.R-project.org/src/contrib:
  cannot download all files

Warning in install.packages :
  URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': status was '400 Bad Request'

Warning in install.packages :
  URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': status was '400 Bad Request'
Warning in install.packages :
  unable to access index for repository https://R-Forge.R-project.org/src/contrib:
  cannot download all files
Warning in install.packages :
  dependency ‘grid’ is not available
Warning in install.packages :
  unable to access index for repository https://www.stats.ox.ac.uk/pub/RWin/bin/macosx/mavericks/contrib/3.3:
  Line starting '<!DOCTYPE html> ...' is malformed!
Warning in install.packages :
  URL 'http://www.omegahat.net/R/bin/macosx/mavericks/contrib/3.3/PACKAGES.gz': status was '404 Not Found'
Warning in install.packages :
  URL 'http://www.omegahat.net/R/bin/macosx/mavericks/contrib/3.3/PACKAGES': status was '404 Not Found'
Warning in install.packages :
  unable to access index for repository http://www.omegahat.net/R/bin/macosx/mavericks/contrib/3.3:
  cannot download all files
Warning in install.packages :
  URL 'https://R-Forge.R-project.org/bin/macosx/mavericks/contrib/3.3/PACKAGES.gz': status was '400 Bad Request'
Warning in install.packages :
  URL 'https://R-Forge.R-project.org/bin/macosx/mavericks/contrib/3.3/PACKAGES': status was '400 Bad Request'
Warning in install.packages :
  unable to access index for repository https://R-Forge.R-project.org/bin/macosx/mavericks/contrib/3.3:
  cannot download all files
Warning in install.packages :
  URL 'https://www.rforge.net/bin/macosx/mavericks/contrib/3.3/PACKAGES.gz': status was '404 Not Found'
Warning in install.packages :
  URL 'https://www.rforge.net/bin/macosx/mavericks/contrib/3.3/PACKAGES': status was '404 Not Found'
Warning in install.packages :
  unable to access index for repository https://www.rforge.net/bin/macosx/mavericks/contrib/3.3:
  cannot download all files

然后我跑的时候:

library(ggplot2)

我收到了错误:

Error : package ‘grid’ does not have a namespace
Error: package or namespace load failed for ‘ggplot2’

我现在不确定该怎么做。我看过类似的帖子 (R error package grid does not have a namespace),但他们的解决方案不适用于我。我的任何库中都没有保存网格,因为我已经卸载了它(使用 remove.packages())。

我的 sessionInfo() 如下:

R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.5 (Mavericks)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] ggenealogy_0.2.0

loaded via a namespace (and not attached):
[1] rsconnect_0.4.3 tools_3.3.1 

任何建议将不胜感激!

【问题讨论】:

    标签: ggplot2 error-handling namespaces r-grid


    【解决方案1】:

    grid是红鲱鱼,它自带R,无需尝试重​​新安装(否则更新R本身)。

    ggplot2 你应该从 CRAN 或 github 安装,而不是 R-forge。尝试 CRAN 存储库。

    【讨论】:

    • 感谢您的帮助。我现在确实尝试了 install.packages("ggplot2", repos='cran.us.r-project.org')。这只给了我一个警告:“依赖‘网格’不可用”。然而,当我做库(ggplot2)时,我收到了同样的两个错误(“错误:包‘网格’没有命名空间错误:‘ggplot2’的包或命名空间加载失败”)
    • 尝试重新安装 R 的新副本,如果你有 .Rprofile,请注释掉。
    猜你喜欢
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-19
    • 2017-07-04
    相关资源
    最近更新 更多