简体   繁体   English

r 为 ggplot2 安装色彩空间时出错

[英]r error on installing colorspace for ggplot2

I am an r newbie and would appreciate some help installing ggplot2.我是一个新手,希望得到一些安装 ggplot2 的帮助。 I am using RStudio Version 0.98.1102.我正在使用 RStudio 版本 0.98.1102。 Please see error below.请参阅下面的错误。

install.packages("ggplot2")

runs fine运行良好

library("ggplot2")

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'colorspace' Error: package or namespace load failed for 'ggplot2' loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) 中的错误:没有名为“colorspace”的包错误:“ggplot2”的包或命名空间加载失败

install.packages("colorspace")

Installing package into 'C:/Users/Jessica/Documents/R/win-library/3.1' (as 'lib' is unspecified) There is a binary version available (and will be installed) but the source version is later: binary source colorspace 1.2-4 1.2-5 trying URL '...//cran.rstudio.com/bin/windows/contrib/3.1/colorspace_1.2-4.zip' Warning in install.packages : cannot open: HTTP status was '404 Not Found' Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL '...://cran.rstudio.com/bin/windows/contrib/3.1/colorspace_1.2-4.zip' Warning in install.packages : download of package 'colorspace' failed将软件包安装到 'C:/Users/Jessica/Documents/R/win-library/3.1'(因为 'lib' 未指定)有一个可用的二进制版本(并将被安装),但源版本较晚:二进制源colorspace 1.2-4 1.2-5 尝试 URL '...//cran.rstudio.com/bin/windows/contrib/3.1/colorspace_1.2-4.zip' install.packages 中的警告:无法打开:HTTP 状态为 ' 404 Not Found'下载错误(url,destfile,方法,模式=“wb”,...):无法打开URL'...://cran.rstudio.com/bin/windows/contrib/3.1 /colorspace_1.2-4.zip' install.packages 中的警告:包 'colorspace' 下载失败

Looks like something is a bit messed up with the package meta-information or something in your Rstudio installation.看起来有些东西与包元信息或 Rstudio 安装中的某些东西有些混乱。 A simple work-around to try is to just download the latest colorspace zip file from here: http://cran.r-project.org/web/packages/colorspace/index.html一个简单的尝试解决方法是从这里下载最新的色彩空间 zip 文件: http : //cran.r-project.org/web/packages/colorspace/index.html

Then install by running install.packages("c:/path/to/downloaded/zip/file/colorspace_1.2-5.zip")然后通过运行install.packages("c:/path/to/downloaded/zip/file/colorspace_1.2-5.zip")

When you type in install.packages("ggplot2") into the console, RStudio is pre-programmed to also install the dependencies (ie the other packages ggplot needs to run properly).当您在控制台中输入install.packages("ggplot2") ,RStudio 被预编程为也安装依赖项(即其他包 ggplot 需要正常运行)。 In this case, the issue appears to be with the colorspace package not being able to installed.在这种情况下,问题似乎是无法安装colorspace包。 This is likely because you're running Yosemite and when RStudio looks to install colorspace, it searches for it on the CRAN, it can't find it for some reason:这可能是因为您正在运行 Yosemite 并且当 RStudio 想要安装色彩空间时,它会在 CRAN 上搜索它,但由于某种原因找不到它:

cannot open URL 'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.1/colorspace_1.2-4.tgz'

You should be able to overcome this by installing the colorspace package yourself via the CRAN: http://cran.r-project.org/web/packages/colorspace/index.html .您应该能够通过 CRAN 自己安装colorspace包来克服这个问题: http : //cran.r-project.org/web/packages/colorspace/index.html

Try to install the color space separately and reload the package inside R studio again .尝试单独安装色彩空间并再次将包重新加载到 R studio 中。

install.packages('ggplot2')
install.packages('colorspace')
library(ggplot2)

Hope this helps!希望这可以帮助!

Sometimes when the Curl version is not updated, problem with installing the packages happens.有时当 Curl 版本没有更新时,安装包会出现问题。 For resolving the problem in Linux, you could use the following command to update your Curl to tha last version:为了解决 Linux 中的问题,您可以使用以下命令将您的 Curl 更新到最新版本:

sudo apt-get install libcurl4-openssl-dev libxml2-dev

To me, it started giving this error when I updated all my packages using the available option "Packages" in R studio, it was working well before.对我来说,当我使用 R studio 中的可用选项“Packages”更新所有包时,它开始出现此错误,它之前运行良好。 After trying a few mentioned solutions in google and failed, I updated my R version and installed the packages, it worked.在谷歌中尝试了一些提到的解决方案并失败后,我更新了我的 R 版本并安装了软件包,它起作用了。

Similar to the original question, I recently encountered this issue with colormap 2.0.0, ggplot2 3.3.2, R 4.0.3, and RStudio 1.3.1093 on Windows.与原始问题类似,我最近在 Windows 上使用 colormap 2.0.0、ggplot2 3.3.2、R 4.0.3 和 RStudio 1.3.1093 遇到了这个问题。 install.packages("ggplot2") reports success even though it does not install colormap and library(ggplot2) therefore fails. install.packages("ggplot2")报告成功,即使它没有安装 colormap 和library(ggplot2)因此失败。 In my case, install.packages("colormap") failed to locate the 2.0.0 binaries, retrieving the 1.4.1 sources instead.就我而言, install.packages("colormap")未能找到 2.0.0 二进制文件,而是检索 1.4.1 源。 Downloading the 2.0.0 binary from https://CRAN.R-project.org/package=colorspace , as suggested in other answers, failed with正如其他答案中所建议的那样,从https://CRAN.R-project.org/package=colorspace下载 2.0.0 二进制文件失败了

> install.packages("C:/Users/<username>/Downloads/colorspace_2.0-0.zip") # note use of forward slashes to avoid the backlash escaping problems @Paul M mentions in his comment on @L P's answer -- \\ instead of just \ also works
Warning in install.packages :
  package ‘C:/Users/<username>/Downloads/colorspace_2.0-0.zip’ is not available for this version of R

What resolved this for me was including type = "win.binary" in install.packages() 's arguments when installing from the download.对我来说解决这个问题的是在从下载安装时在install.packages()的参数中包含type = "win.binary"

install.packages("C:/Users/<username>/Downloads/colorspace_2.0-0.zip", type = "win.binary")

Having done this, install.packages("colorspace") also succeeds (both in session and after remove.packages("colorspace") and restarting R).完成此操作后, install.packages("colorspace")也成功(在会话中和remove.packages("colorspace")并重新启动 R 之后)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM