我正在使用DeployR for Microsoft R Server 2016,8.0.5 for 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'
可能有什么不对?谢谢。
答案 0 :(得分: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
中不同功能的更多信息,请访问here