JDataFrame

Bitbucket | Bamboo

JDataFrame ExampleThe JDataFrame framework facilitates the representation of data in Java which can be exported as JSON and then converted into a properly formatted data frame in the R Project for Statistical Computing using the RSONIO package.

The JDataFrame framework relies on the Google GSON API for serialization. Developers can use the JDataFrameBuilder to quickly build JDataFrame instances as we have demonstrated in the example R script below:

groovyJars <- list (
    "C:/development/projects/rGroovy/groovy.jars/groovy-2.4.5-indy.jar",
    "C:/development/projects/rGroovy/groovy.jars/ivy-2.4.0.jar"
)

options(GROOVY_JARS=groovyJars)

library(rGroovy)

rGroovy::Initialize()

script <- paste (
    "@Grab(group='com.coherentlogic.r.integration', module='jdataframe-core', version='0.8.5-RELEASE')",
    "import com.coherentlogic.r.integration.data.frame.JDataFrameBuilder",
    "def codes = ['WV', 'VA'] as String[]",
    "def descriptions = ['West Virginia', 'Virginia'] as String[]",
    "return new JDataFrameBuilder()",
    ".addColumn('Code', codes)",
    ".addColumn('Description', descriptions)",
    ".toJson()", sep="\n")

json <- rGroovy::Evaluate(groovyScript = script)

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

produces the following data frame:

> tempDF
    Description Code
1 West Virginia   WV
2      Virginia   VA
[disqus_embed]