Hi Folks,

If you need to send data from Java to R you may consider using the
JDataFrame API -- which is used to convert data into JSON which then
can be converted into a data frame in R.

Here's the project page:

https://coherentlogic.com/middleware-development/jdataframe/

and here's a partial example which demonstrates what the API looks like:

String result = new JDataFrameBuilder()
    .addColumn("Code", new Object[] {"WV", "VA", })
    .addColumn("Description", new Object[] {"West Virginia", "Virginia"})
    .toJson();

and in R script we would need to do this:

temp <- RJSONIO::fromJSON(json)
tempDF <- as.data.frame(temp)

which yields a data frame that looks like this:

> tempDF
    Description Code
1 West Virginia   WV
2      Virginia   VA

It is my intention to deploy this project to Maven Central this week,
time permitting.

Questions and comments are welcomed.

Tom

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to