Rstudio install.packages失败解决方式

初学R语言出现了无法安装R包的情况:

install.packages(“vcb”)
Warning in install.packages :
unable to access index for repository https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib:
无法打开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/PACKAGES’
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/
Warning in install.packages :
unable to access index for repository https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib:
无法打开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/PACKAGES’
Warning in install.packages :
package ‘vcb’ is not available (for R version 3.6.2)
Warning in install.packages :
unable to access index for repository https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.6:
无法打开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.6/PACKAGES’

解决方法:
我试了以下几个步骤最终成功了。
1.进入到R的安装目录,编辑/etc/Rprofile.site,加上一行添加 options(download.file.method=“libcurl”),重新打开Rstudio。
2.在tools-global options-packages中切换下载的镜像,选择一个中国的镜像,如https://mirrors.tuna.tsinghua.edu.cn。
3.有可能是自己把R包的名字打错了,犯了低级错误,如把vcd写成了vcb,哈哈,尴尬。

运行成功:
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.6/vcd_1.4-7.zip’
length 1561131 bytes (1.5 MB)
downloaded 1.5 MB

package ‘zoo’ successfully unpacked and MD5 sums checked
package ‘colorspace’ successfully unpacked and MD5 sums checked
package ‘lmtest’ successfully unpacked and MD5 sums checked
package ‘vcd’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Administrator\AppData\Local\Temp\RtmpSm2usd\downloaded_packages

  • 6
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值