我正在编写一个我想要包含在用户定义的包中的函数(MYPACKAGE)。功能如下:
readSchedule <- function(FILE){
WB = loadWorkbook(FILE)
WS= readWorksheet(WB, sheet = 'Sheet1',header = TRUE)
return(WS)
}
其中FILE是我想要阅读的Excel文件的名称。编写此函数时,我希望它导入XLConnect,因为它是它使用的包。我放置了定义函数的头代码:
@param FILE Excel file
@return Excel data
@export
@import XLConnect
我还将导入(XLConnect)添加到NAMESPACE和MYPACKAGE的DESCRIPTION文件中。包构建正常(或至少在第一次切割它似乎构建好)但当我运行“检查包”它失败并给我以下错误:
* installing *source* package 'MYPACKAGE' ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
我有正确的Java版本,可以正常加载rJava。我试过导入rJava(类似于XLConnect),但我得到了同样的错误。以下是我的sessionInfo:
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MYPACKAGE
loaded via a namespace (and not attached):
[1] chron_2.3-45 data.table_1.9.4 digest_0.6.8 lubridate_1.3.3 memoise_0.2.1 plyr_1.8.1
[7] Rcpp_0.11.1 reshape2_1.4 rJava_0.9-6 stringr_0.6.2 tools_3.1.2 XLConnect_0.2-7
答案 0 :(得分:1)
看起来您正在安装了64位版本Java的Windows 64位计算机上构建程序包。使用R CMD check
检查程序包时,默认情况下R也会尝试检查其他子架构(i386,32位)上的程序包,在您的情况下,这需要32位Java安装。
如果您还要为i386
检查您的软件包,您可能还需要另外安装Java 32位。另一种方法是将选项--no-multiarch
传递给您的R CMD check
来电,例如R CMD check --no-multiarch MYPACKAGE
。