Cannot install library(xlsx) in R and look for an alternative
Asked Answered
D

6

6

I use R version 3.0.3. I was not able to install library(xlsx). Error message:

Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Program Files/R/R-3.0.3/library/rJava/libs/x64/rJava.dll':

LoadLibrary failure:  The specified module could not be found.

I then tried to install rjava on its own. Got the error message below:

library("rJava", lib.loc="C:/Program Files/R/R-3.0.3/library") Error : .onLoad failed in loadNamespace() for 'rJava', details: call: inDL(x, as.logical(local), as.logical(now), ...) error: unable to load shared object 'C:/Program Files/R/R-3.0.3/library/rJava/libs/x64/rJava.dll': LoadLibrary failure: The specified module could not be found.

Is there another way to load excel file in R?

Deicide answered 22/4, 2014 at 2:5 Comment(8)
possible duplicate of Importing .xlsx file into RAbernon
Have a look at this blog post on rJava r-statistics.com/2012/08/… Make sure you have the right version of java.Endoergic
May be it's time to test the new openxlsx package which doens't rely on Java cran.r-project.org/web/packages/openxlsx/index.htmlItching
@Itching Nice find Didn't know this existed. +1Endoergic
@Itching package ‘openxlsx’ is not available (for R version 3.0.3) :( :( :(Deicide
You should only have gotten that message if your repository were incomplete ( or you were on a Mac), So please provide more details about he code you are using and your setup.Heliotropism
@TylerRinker I think this package is new, I'm really happy to have a decent cpp based solution to xlsx IO.Itching
This will not solve this specific issue, but perhaps you might want to use readxl: github.com/hadley/readxl . It has no external dependencies.Camouflage
H
10

Here are some possible solutions:

  1. Install 64-bit version of Java. Here is the download link of Java.
  2. Re-install rJava.
  3. Manually set the directory of your Java location by setting it before loading the library

    Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre7") # for 64-bit version Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\\jre7") # for 32-bit version library(rJava)

Source: here

Handicraftsman answered 6/11, 2015 at 8:30 Comment(0)
T
9

This problem is generally caused by x86 vs x64 bit differences between the R session and the install Java edition. By default Java installs the x86 version and you have to search for the x64 version. if you look at the version of Java you have installed and then open your R session to the same if your using R studio you can click on Tools.GlobalOptions and then select the version you need. ;-)

Tamathatamaulipas answered 4/12, 2014 at 23:8 Comment(0)
E
2

For mac user, installing Java for OS X 2014-001 works for me https://support.apple.com/kb/DL1572?locale=en_US

Eiten answered 13/7, 2015 at 2:37 Comment(1)
Nothing changed for me after I installed this.Copperhead
G
1

For Windows 10 Pro users 64 bit OS, use

Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jre1.8.0_144")
Gas answered 19/9, 2017 at 10:35 Comment(0)
S
0

install.packages("openxlsx") try to install OPENXLSX instead of XLSX package. Now, the required library will work properly. library(openxlsx)

Scrutable answered 9/12, 2022 at 22:5 Comment(0)
I
-1

For MAC OS X follow these steps in order:

  1. Use this command in the Terminal: sudo R CMD javareconf

  2. Restart BaseR and RStudio...

  3. in RStudio console: install.packages("xlConnect")

  4. in RStudio console: library(xlConnect)

  5. in RStudio console: library(xlsx)

Problem solved!

Intoxication answered 1/5, 2019 at 17:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.