-1

我将 DeployR 用于 Microsoft R Server 2016,8.0.5 用于 Windows。

我想安装包 XLConnect 来处理 Excel 文件:

> install.packages("XLConnect")
package 'XLConnect' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Windows\Temp\RtmpYnppvI\downloaded_packages

> library("XLConnect")
Console Error there is no package called 'XLConnect'
API Error there is no package called 'XLConnect'

有什么问题?谢谢你。

4

1 回答 1

0

如果我们正在使用deployR,则有一个名为的包deployrUtils,它已经具有deployrPackage加载和安装包的功能(如果不存在)

library(deployrUtils)
deployrPackage("XLConnect")

下面是代码片段deployrPackage

deployrPackage <- function(pkgs, lib, repos = getOption("repos"), ...) {
  #
  # this function checks to see if the declared pkgs are installed. If not, 
  # pkgs are installed. In all cases the packages are loaded
  #
  if (!suppressWarnings(require(pkgs, character.only = TRUE))) {
    install.packages(pkgs, lib, repos = repos, ...)
    if(!suppressWarnings(require(pkgs, character.only = TRUE))) {
      stop("Package not found")
    }
  }

  suppressWarnings(require(pkgs, character.only = TRUE))
}

deployrUtils可以在此处找到有关不同功能的更多信息

于 2017-02-15T09:41:05.760 回答