Rstudio安裝packages時報錯,原因可能是這樣

最近接觸R語言,安裝好Rstudio後,需要安裝R的第三方包mirt。執行步驟如下:

在這裏插入圖片描述
在這裏插入圖片描述

正當滿心歡喜地期待包的安裝時,結果出現了下面的情況:
install.packages("mirt")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/likailei/Documents/R/win-library/3.6
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
  package ‘mirt’ is not available (for R version 3.6.0)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.6:
  cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/PACKAGES'
什麼鬼?!

此處省略5000字的辛苦排錯的歷程描述,直接貼上解決方案:

Rstudio默認使用的國外鏡像源,國內無法正常訪問。

Rstudio設置如下
Tools>global options>packages
在這裏插入圖片描述
更改鏡像源後,重新執行安裝操作。

install.packages("mirt")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/likailei/Documents/R/win-library/3.6
(as ‘lib’ is unspecified)
also installing the dependencies ‘permute’, ‘GPArotation’, ‘Rcpp’, ‘vegan’, ‘Deriv’, ‘dcurver’, ‘RcppArmadillo’

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/permute_0.9-5.zip'
Content type 'application/zip' length 505181 bytes (493 KB)
downloaded 493 KB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/GPArotation_2014.11-1.zip'
Content type 'application/zip' length 162104 bytes (158 KB)
downloaded 158 KB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/Rcpp_1.0.1.zip'
Content type 'application/zip' length 4494896 bytes (4.3 MB)
downloaded 4.3 MB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/vegan_2.5-5.zip'
Content type 'application/zip' length 3861520 bytes (3.7 MB)
downloaded 3.7 MB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/Deriv_3.8.5.zip'
Content type 'application/zip' length 133828 bytes (130 KB)
downloaded 130 KB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/dcurver_0.9.1.zip'
Content type 'application/zip' length 639915 bytes (624 KB)
downloaded 624 KB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/RcppArmadillo_0.9.400.3.0.zip'
Content type 'application/zip' length 2276463 bytes (2.2 MB)
downloaded 2.2 MB

trying URL 'https://mirrors.tongji.edu.cn/CRAN/bin/windows/contrib/3.6/mirt_1.30.zip'
Content type 'application/zip' length 2572772 bytes (2.5 MB)
downloaded 2.5 MB

package ‘permute’ successfully unpacked and MD5 sums checked
package ‘GPArotation’ successfully unpacked and MD5 sums checked
package ‘Rcpp’ successfully unpacked and MD5 sums checked
package ‘vegan’ successfully unpacked and MD5 sums checked
package ‘Deriv’ successfully unpacked and MD5 sums checked
package ‘dcurver’ successfully unpacked and MD5 sums checked
package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
package ‘mirt’ successfully unpacked and MD5 sums checked
完美!!!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章