2

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

1
  • I also tried it with [[Ljava/lang/String instead of [[S but that does not work either... Commented Aug 30, 2011 at 15:06

2 Answers 2

1

[[Ljava/lang/String;

This will work

Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.