0
votes

Cannot install R package xlsx.

I have previously used the package on other PCs and had no trouble with it whatsoever, but am having difficulty with a new PC. From what I can tell the issue is something to do with Java. Currently tried:

  • Downloading Java Development Kit
  • Downloading JRE
  • Editing environment variables to point to the right Java (for both of the above)
  • Running through the R console (both 32 and 64 bit)
  • Uninstalling and reinstalling Rstudio / R

install.packages("xlsx")
`Installing package into ‘C:/Users/Fred Goktas/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
xlsx 0.5.7 0.6.1 FALSE
installing the source package ‘xlsx’
trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.6.1.tar.gz'
Content type 'application/x-gzip' length 315441 bytes (308 KB)
downloaded 308 KB
* installing source package 'xlsx' ...
** package 'xlsx' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
* installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*
arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/rJava/libs/i386/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.3/bin/x64/R" CMD INSTALL -l
"C:\Users\Fred Goktas\Documents\R\win-library\3.3"
C:\Users\FREDGO~1\AppData\Local\Temp\RtmpYLz0xk/downloaded_packages/xlsx_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status

Package should install without any troubles.

1
Have you properly installed rJava on that machine? These tips might help: cimentadaj.github.io/blog/…MrFlick
Do you have the RJava package installed and the JAVA HOME environment variable set? I suggest that you try the openxlsx package if you want to manipulate xlsx files in R. It does not rely on Java.slava-kohut
Simply try: install.packages('openxlsx') You can achieve many tasks you need xlsx for with openxlsx, but the latter removes the dependency on Java while providing the same speed.slava-kohut
If you would like to fully uninstall then clean reinstall R and RStudio, follow the steps here: stackoverflow.com/a/61187094/1953250ozturkib

1 Answers

0
votes

Unless you have no compelling reason to use xlsx, I would suggest you consider readxl because it has no external dependencies.