0

I am using rServe to integrate R and Java. I'm able to call R function from Java and that function returns summary of variable. But the problem is I am unable to display that summary in Java. Below is the snippet of Java code I'm using.

RConnection c = new RConnection();
c.eval("library(ggplot)");
REXP desc = c.eval("describe(mpg)");
System.out.println(desc.asString());

describe function in R gives following output.

describe(mpg)
mpg 

 11  Variables      234  Observations
--------------------------------------------------------------------------
manufacturer 
       n  missing distinct 
     234        0       15 

audi (18, 0.077), chevrolet (19, 0.081), dodge (37, 0.158), ford (25,
0.107), honda (9, 0.038), hyundai (14, 0.060), jeep (8, 0.034), land
rover (4, 0.017), lincoln (3, 0.013), mercury (4, 0.017), nissan (13,
0.056), pontiac (5, 0.021), subaru (14, 0.060), toyota (34, 0.145)

1 Answer 1

1

The way that I capture my R output in java is:

String ret = c.eval("paste(capture.output(describe(mpg))),collapse='\\n')").asString();
System.out.print(ret);
Sign up to request clarification or add additional context in comments.

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.