1

I am writing a function that i want to include in a user-defined package (MYPACKAGE). The function is a follows:

readSchedule <- function(FILE){
    WB = loadWorkbook(FILE)
    WS= readWorksheet(WB, sheet = 'Sheet1',header = TRUE)
    return(WS)
}

where FILE is the name of the Excel file i want to read. When writing this function, I want it to import XLConnect, since that is the package it uses. I placed header code defining the function:

@param FILE Excel file
@return Excel data
@export
@import XLConnect

I have also added import(XLConnect) to the NAMESPACE and the DESCRIPTION file of MYPACKAGE. The package builds fine (or at least at first cut it appears to build OK) but when i run "Check Package" it fails and gives me the following error:

* 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'

I have the correct version of Java and can load rJava just fine. i've tried importing rJava (similar to XLConnect) but i get the same error. Below is my 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 
4

1 回答 1

1

It looks like you are building your package on a Windows 64-bit machine with a 64-bit version of Java installed. When checking your package using R CMD check, R by default also attempts to check your package on other sub-architectures (i386, 32-bit) which in your case would in addition require a 32-bit installation of Java.

If you want to check your package also for i386 you may just additionally install Java 32-bit. The other option is to pass the option --no-multiarch to your R CMD check call, e.g. R CMD check --no-multiarch MYPACKAGE.

于 2015-07-28T15:19:35.300 回答