如何安装R的readxl软件包?

时间:2019-02-19 23:08:21

标签: r readxl

我正在尝试为R安装 readxl 软件包。

以下是RStudio的输出:

To learn more and/or disable this warning message see the "Use secure download method for HTTP" option in Tools -> Global Options -> Packages.
> library('readxl')
Error in library("readxl") : there is no package called ‘readxl’
> install.packages("readxl")
Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Installing package into ‘C:/Users/Lenovo/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
  package ‘readxl’ is not available (for R version 3.5.0)
Warning in install.packages :
  unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.5:
  cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.5/PACKAGES'
> 

以下是R的控制台输出:

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("readxl")
Installing package into ‘C:/Users/Lenovo/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-35~1.0/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
  cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Warning: unable to access index for repository https://cloud.r-project.org/bin/windows/contrib/3.5:
  cannot open URL 'https://cloud.r-project.org/bin/windows/contrib/3.5/PACKAGES'
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
  InternetOpenUrl failed: ''
2: package ‘readxl’ is not available (for R version 3.5.0) 
> 

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

错误消息似乎似乎在告诉您,R无法连接下载软件包。这里有一些想法:

  • 您的用户个人资料是否具有管理权限?我不是Windows的大用户,但是您在技术上正在尝试添加软件,有时这需要升级的特权。也许尝试在Windows中以管理员身份运行R,针对这一问题,看是否是问题所在。 (似乎不太可能。)
  • 如果这是防火墙问题,则可以尝试为R和/或Cran存储库的防火墙设置添加例外。
  • 您是否尝试过考虑相关软件包? install.packages(“ readxl”,dependencies = TRUE)(这也可能导致其自身的问题,因此请注意一下自己。)
  • 您可以下载其他任何软件包吗?当您可以访问Internet进行堆叠张贴时,正在询问一个相当入门的问题,并且URL有效,因此R的安装可能存在配置问题。如果所有其他操作均失败,则可能希望卸载/重新安装R在您的系统上(可能还有Rstudio的情况下),因为如果损坏,这可能有助于修复。使用文件校验和,这是有原因的。