0

I have installed the xlsx package into my R, and I have verify that it is there. But when I try to open the library xlsx, it said that package or namespace load failed for xlsx.

This is a R version 3.6.0 and I am following a tutorial in https://www.tutorialspoint.com/r/r_excel_files.htm

> any(grepl("xlsx",installed.packages()))
[1] TRUE
> # Load the library into R workspace.
> library("xlsx")
Error: package or namespace load failed for ‘xlsx’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry

According to the tutorial, the output should be

[1] TRUE
Loading required package: rJava
Loading required package: methods
Loading required package: xlsxjars
user39178
  • 123
  • 4
  • 2
    Package XLSX needs JAVA Development environment, try searching for the same problem in SO, there are many answers to this same problem. – Fausto Carvalho Marques Silva Jun 03 '19 at 19:25
  • `any(grepl("xlsx",...))` is wrong for at least two (big) reasons: (1) it might match `openxlsx`; and (2) it is attempting to match against all other package's attributes (from `colnames(installed.packages())`, you see all of the following: Package, LibPath, ..., Depends, Imports, ..., Suggests, Enhances, ... so if a package *suggests* "openxlsx", you will find a match. Not what you intend, I suspect.) More-specific tests: `any(grepl("xlsx", installed.packages()[,1]))`, or just `"xlsx" %in% installed.packages()[,1]`. – r2evans Jun 03 '19 at 20:39

0 Answers0