0

Is there a way to convert a JSONArray to a R data frame using Java?

We felt it would a better way to convert a JSONArray to a R data frame, rather than writing it to a file/db and then again retrieve it from R.

Any suggestions/recommendations of libraries would be awesome.

user3616977
  • 527
  • 2
  • 5
  • 14

1 Answers1

1

First for working with R language in Java project you need to use some JVM-based R interpreter/interface. For instance you can look on next few options:

  • Renjin - JVM-based interpreter for the R language for statistical computing;
  • rJava - R to Java interface;
  • FastR - an implementation of the R Language in Java atop Truffle.

Approach to converting will depend on what tool you choose.

Hleb
  • 7,037
  • 12
  • 58
  • 117
  • We use rJava, but are not found a way to convert a JSON to data frame. If there is a way, please let us know...it would be great – user3616977 Jun 27 '18 at 10:40
  • I didn't work with rJava unfortunately, and I don't pretty well know R, but I think it will be easier to serialize JSONArray to String JSON and then process it with R approach, something like in this question - https://stackoverflow.com/questions/16947643/getting-imported-json-data-into-a-data-frame. – Hleb Jun 27 '18 at 10:55