无法安装特定的R包

问题描述 投票:0回答:1

我尝试在 R 中安装

sf
软件包,但它返回错误并且无法安装该软件包。

警告信息说

软件包“sf”的安装具有非零退出状态。

您能告诉我如何安装该软件包吗?我使用的是 Windows R 版本 3.6.1。

Platform: x86_64-w64-mingw32/x64 (64-bit)

以下是所有留言:

> install.packages("sf")
Installing package into ‘C:/Users/***/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘wk’, ‘s2’, ‘units’


  There are binary versions available but the source versions are later:
      binary source needs_compilation
wk     0.4.1  0.5.0              TRUE
s2     1.0.4  1.0.7              TRUE
units  0.7-1  0.7-2              TRUE
sf     0.9-8  1.0-4              TRUE

installing the source packages ‘wk’, ‘s2’, ‘units’, ‘sf’

trying URL 'https://cran.rstudio.com/src/contrib/wk_0.5.0.tar.gz'
Content type 'application/x-gzip' length 138686 bytes (135 KB)
downloaded 135 KB

trying URL 'https://cran.rstudio.com/src/contrib/s2_1.0.7.tar.gz'
Content type 'application/x-gzip' length 2235408 bytes (2.1 MB)
downloaded 2.1 MB

trying URL 'https://cran.rstudio.com/src/contrib/units_0.7-2.tar.gz'
Content type 'application/x-gzip' length 855840 bytes (835 KB)
downloaded 835 KB

trying URL 'https://cran.rstudio.com/src/contrib/sf_1.0-4.tar.gz'
Content type 'application/x-gzip' length 3526535 bytes (3.4 MB)
downloaded 3.4 MB

* installing *source* package 'wk' ...
**  パッケージ 'wk' の解凍および MD5 サムの検証に成功しました 
** using staged installation
** libs

*** arch - i386
c:/Rtools/mingw_32/bin/gcc  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG -I../inst/include/ -I"C:/Users/***/Documents/R/win-library/3.6/cpp11/include"        -O3 -Wall  -std=gnu99 -mtune=generic -c bbox-handler.c -o bbox-handler.o
sh: line 1: c:/Rtools/mingw_32/bin/gcc: No such file or directory
make: *** [C:/PROGRA~1/R/R-36~1.1/etc/i386/Makeconf:208: bbox-handler.o] Error 127
ERROR: compilation failed for package 'wk'
* removing 'C:/Users/***/Documents/R/win-library/3.6/wk'
Warning in install.packages :
  installation of package ‘wk’ had non-zero exit status
* installing *source* package 'units' ...
**  パッケージ 'units' の解凍および MD5 サムの検証に成功しました 
** using staged installation

   **********************************************
   WARNING: this package has a configure script
         It probably needs manual configuration
   **********************************************


** libs

*** arch - i386
rm -Rf units.dll RcppExports.o udunits.o
"C:/PROGRA~1/R/R-36~1.1/bin/i386/Rscript.exe" "../tools/winlibs.R"
mkdir -p ../inst
rm -Rf ../inst/share
cp -r ../windows/udunits-2.2.20/share ../inst/
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG -DUDUNITS2_DIR=0 -I../windows/udunits-2.2.20/include -I"C:/Program Files/R/R-3.6.1/library/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
sh: line 1: c:/Rtools/mingw_32/bin/g++: No such file or directory
make: *** [C:/PROGRA~1/R/R-36~1.1/etc/i386/Makeconf:215: RcppExports.o] Error 127
ERROR: compilation failed for package 'units'
* removing 'C:/Users/***/Documents/R/win-library/3.6/units'
Warning in install.packages :
  installation of package ‘units’ had non-zero exit status
ERROR: dependency 'wk' is not available for package 's2'
* removing 'C:/Users/***/Documents/R/win-library/3.6/s2'
Warning in install.packages :
  installation of package ‘s2’ had non-zero exit status
ERROR: dependencies 's2', 'units' are not available for package 'sf'
* removing 'C:/Users/***/Documents/R/win-library/3.6/sf'
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\***\AppData\Local\Temp\RtmpuiUgtA\downloaded_packages’

我指定了包的 url,如下所示,但它也返回错误;

> install.packages("https://cran.r-project.org/src/contrib/sf_1.0-4.tar.gz", repos=NULL)
Installing package into ‘C:/Users/***/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/sf_1.0-4.tar.gz'
Content type 'application/x-gzip' length 3526535 bytes (3.4 MB)
downloaded 3.4 MB

ERROR: dependencies 's2', 'units' are not available for package 'sf'
* removing 'C:/Users/***/Documents/R/win-library/3.6/sf'
Warning in install.packages :
  installation of package ‘C:/Users/***/AppData/Local/Temp/RtmpuiUgtA/downloaded_packages/sf_1.0-4.tar.gz’ had non-zero exit status
r r-sf install.packages
1个回答
0
投票

兄弟,我绝望地将问题交给chatGPT,它给了我一个解决方案,但我不确定它是否有效(我猜它有效)。我无法判断这是否有效,因为我是 R 的新手。这是如何进行的:

install.packages("DBI", type = "win.binary")
© www.soinside.com 2019 - 2024. All rights reserved.