Tobi
Tobi

Reputation: 2040

Problem passing String[][] from Java to R using rJava

Is it possible to return from Java a String[][] to R using rJava?

I call the method

public String[][] readFromTable(String tableName, String security,
        String[] fields, String startTime, String endTime, boolean reverse)

from R with

   out <- .jcall(obj, "[[S", "readFromTable", tableName, security, .jarray(fields),
    start, end, reverse)

When I change the return type of the method to String[] everything works just fine, I experimented with the parameters and I am pretty sure that the problem is the String[][].

Has anyone got an idea?

EDIT 1:
Sorry, I forgot the error message:
Error in .jcall(obj, "[[S", "readFromTable", tableName, security, .jarray(fields), : method readFromTable with signature (Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)[[S not found

EDIT 2
I just figured out that it works if I return a Double[][]...so maybe there is a bug in the String JNI implementation in the rJava package but that's hard to believe

Upvotes: 2

Views: 891

Answers (2)

Vineeth Mohan
Vineeth Mohan

Reputation: 19273

[[Ljava/lang/String;

This will work

Upvotes: 1

Drey
Drey

Reputation: 3364

Have you tried to play with the .jarray? It was an issue of my problems.

.jarray(fields, contents.class="Ljava/lang/String")

Upvotes: 0

Related Questions