您好,登錄后才能下訂單哦!
在Rstudio中安裝package時(shí)出現(xiàn)錯(cuò)誤如何解決?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
一、 install.packages('REmap')無(wú)法安裝package:錯(cuò)誤:“無(wú)法與服務(wù)器建立連接”
解決方式:切換下載的鏡像
方法一:在Rstudio菜單欄:tools-global options-packages中切換下載的鏡像
方法二:修改文件,在安裝文件夾中找到Rprofile.site文件,我的路徑是D:\Program Files\R\R-3.4.1\etc,用記事本打開,在里面添加語(yǔ)句:
# set a CRAN mirror local({r <- getOption(“repos”) r[“CRAN”] <- “http://mirrors.tuna.tsinghua.edu.cn/CRAN/” options(repos=r)}
在網(wǎng)站:https://mirrors.tuna.tsinghua.edu.cn/CRAN/下載好需要的package
1.在R studio下,選擇packages
2.選擇Install
3.Install from欄選擇Package Archive File(.zip;.tar.gz)
4.Package archive欄點(diǎn)擊Browser,選擇剛才下載的文件
5.點(diǎn)擊Install,進(jìn)行安裝
致此,手動(dòng)安裝R包完成。安裝提示如下
推薦第一種安裝方式:因?yàn)榈谝环N安裝方式會(huì)自動(dòng)安裝依賴的包,而第二種方式,除了下載你想安裝的包還要下載所有依賴的包,這就有一定的難度了。
補(bǔ)充:Rstudio安裝packages時(shí)報(bào)錯(cuò),原因可能是這樣
最近接觸R語(yǔ)言,安裝好Rstudio后,需要安裝R的第三方包mirt。
正當(dāng)滿心歡喜地期待包的安裝時(shí),結(jié)果出現(xiàn)了下面的情況:
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字的辛苦排錯(cuò)的歷程描述,直接貼上解決方案:
Rstudio默認(rèn)使用的國(guó)外鏡像源,國(guó)內(nèi)無(wú)法正常訪問(wèn)。
Rstudio設(shè)置如下
Tools>global options>packages
更改鏡像源后,重新執(zhí)行安裝操作。
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.#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.#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.#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.#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.#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.#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.#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.#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
看完上述內(nèi)容,你們掌握在Rstudio中安裝package時(shí)出現(xiàn)錯(cuò)誤如何解決的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。