0

I have the sqldf code below to merge two data frames. I understand I need the RH2 package. I pasted the error onto google to find solutions but most of the solutions listed is because of people being unable to download the rJava library. Do I absolutely need that library or can I run the code below without the rJava library? I'm waiting on my system admin to help me install java as I'm not allowed to. Solutions I've found 1 and 2 . If there's alternatives I can do or use for sqldf to get the code to run, please let me know.

CODE (w source link) :

library(sqldf)
library(RH2)


nr1 <- 100
nc1 <- 4682 
df1 <- as.data.frame(matrix(seq_len(nr1*nc1), nr1))

nr2 <- 100
nc2 <- 4903
df2 <- as.data.frame(matrix(seq_len(nr2*nc2), nr2))

options(sqldf.driver = "H2")
res <- sqldf("select * from df1 a
       left join df2 b on a.V1 = b.V1
        and a.V2 between b.V3 and b.V4")

ERROR:

Loading required package: RJDBC
Loading required package: rJava
java.home option: 
JAVA_HOME environment variable: D:\Ash\Java\jre7
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: JAVA_HOME cannot be determined from the Registry
Error: package ‘rJava’ could not be loaded
In addition: Warning message:
In fun(libname, pkgname) :
  Java home setting is INVALID, it will be ignored.
Please do NOT set it unless you want to override system settings.
Error in !dbPreExists : invalid argument type
Ash S
  • 119
  • 5
  • H2 is a java database and can't be run without java. There is something wrong with your java installation. Try googling for *install rjava windows*. When copying someone else's online code please reference the link where it was copied from. That link already provided alternatives that sqldf supports. – G. Grothendieck Nov 19 '21 at 15:35
  • I will do that. Thank you for all your help. I edited my post w source link :) – Ash S Nov 19 '21 at 16:34

0 Answers0