R:中的错误(只有源代码形式的包,可能需要编译C/C++/Fortran)

wan*_*nax 26 install yaml r stringi

我正在尝试在R-Studio中安装'yaml'和'stringi'软件包,它不断给我这些错误:

> install.packages("stringi")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘stringi’
These will not be installed
Run Code Online (Sandbox Code Playgroud)

要么

> install.packages('yaml')
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘yaml’
These will not be installed
Run Code Online (Sandbox Code Playgroud)

如何正确安装这些?

Lyz*_*deR 25

该错误是由于R无法在CRAN上找到包的二进制版本,而只是找到包的版本而您的Windows安装无法编译它.通常这不会发生,但在这种情况下是由CRAN的某些镜像的(临时)中断引起的.如果输入:

> getOption('repos')
                                CRAN                            CRANextra 
           "http://cran.rstudio.com" "http://www.stats.ox.ac.uk/pub/RWin" 
attr(,"RStudio")
[1] TRUE
Run Code Online (Sandbox Code Playgroud)

您将看到R "http://cran.rstudio.com"默认使用它来查找要下载的包.如果您看到顶部镜像网页,您可以在顶部看到"http://cran.rstudio.com"实际上将您重定向到世界各地的不同服务器(我假设根据地理位置).

当我遇到上述问题时,我通过手动将repo更改为提供的链接中的一个URL来解决它.如果您收到上述错误,我建议您使用其他国家(甚至大陆).

如果上面的链接发生变化,我会在下面提供一些网址:

  1. 巴西http://nbcgib.uesc.br/mirrors/cran/
  2. 意大利 http://cran.mirror.garr.it/mirrors/CRAN/
  3. 日本 http://cran.ism.ac.jp/
  4. 南非http://r.adu.org.za/
  5. 美国https://cran.cnr.Berkeley.edu/

您需要install.packages按如下方式运行该函数:

install.packages('<package_name>', repo='http://nbcgib.uesc.br/mirrors/cran/')
#or any other url from the list or link
Run Code Online (Sandbox Code Playgroud)

然后其中一个应该从另一个镜像安装二进制文件.


Sta*_*'co 13

您需要安装RTools来构建这样的包(即源包而不是二进制包).安装Rtools后,再试一次install.packages("ggplot2"),R会提示你:

Do you want to attempt to install these from source?
y/n:
Run Code Online (Sandbox Code Playgroud)

(见下图)

你需要回答y,它会尝试编译包,以便安装它.

在此输入图像描述


Ste*_*ink 8

今天遇到这个问题,现在通过首先下载windows二进制文件然后安装例如解决它

install.packages("https://cran.r-project.org/bin/windows/contrib/3.3/stringi_1.1.1.zip", repos =NULL)
Run Code Online (Sandbox Code Playgroud)

只需转到https://cran.r-project.org/然后转到R Binaries/Windows/contrib并将url作为参数复制到install.packages()