B4J Question Running R scripts

EJLib

Member
Licensed User
Longtime User
Hi,

I would like to be able to run "R" language scripts in B4J.

My B4J code pulls data from a database according to user parameters. The next step is to analyze the data and visualize the result using heat maps and line charts,
There are many well developed R scripts that do statistical analysis and visualization.

How do I run and send data to an external R process, then received the result back for displaying in B4J?

Thanks,
Eric
 

billzhan

Active Member
Licensed User
Longtime User
R can be run in a server mode, one package is httpuv ( HTTP 1.0 & websocket). You can exchange data to R process with HTTP request.

The data format could be JSON ( jsonlite package). Binary data (like images) could be encoded as BASE64 string.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I would like to be able to run "R" language scripts in B4J
What are R Language Scripts?

I just know the R.java from Android. But it does not do any calculations or show any graphs....
B4J is not using R-Classes

You can request data from your RDC2 server and use the result as you wish...

Maybe you need to be more precise in your request.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I am currently trying to implement a Renjin script engine library interface so you can run the script from java.
I don't understand 'R' so its a bit slow lol

Got it running so it understands the following (although I don't)
B4X:
Dim engine As jInvokeR
engine.init
engine.Eval("df <- data.frame(x=(1:10) , y=(1:10)+rnorm(n=10))")
engine.Eval("print(df)")
engine.Eval("print(lm(y ~ x, df))")
which produces the following output
x y
1 1 2.537
2 2 3.673
3 3 1.854
4 4 3.946
5 5 5.204
6 6 7.17
7 7 7.038
8 8 10.119
9 9 8.583
10 10 8.538
Call:
lm(formula = y ~ x, data = df)
Coefficients:
(Intercept) x
1.168 0.854

Would that be sufficient for your needs ?
 
Last edited:
Upvote 0
Top