Change category
R Gateway via RServe for InterSystems IRIS Data Platform. Author Shiao-Bin Soong: email, github profile.
ML Toolkit user group is a private GitHub repository set up as part of InterSystems corporate GitHub organization. It is addressed to the external users that are installing, learning or are already using ML Toolkit components. To join ML Toolkit user group, please send a short e-mail at the following address: MLToolkit@intersystems.com and indicate in your e-mail the following details (needed for the group members to get to know and identify you during discussions):
install.packages("Rserve",,"http://rforge.net")
library(Rserve)
Rserve()
Load and Compile IRIS R package (i.e. do $system.OBJ.ImportDir("C:\InterSystems\Repos\R\","*.cls","c",,1)
).
The following ObjectScript code illustrates the simple integration with Rserve:
Set c = ##class(R.RConnection).%New() // Create a R client
Set x = ##class(R.REXPDouble).%New(3.0) // A single double value
Do c.assign("x", x) // Assign the value to R variable x
Do c.eval("y<-sqrt(x)") // Evaluate R script
Set y = c.get("y") // Get the value of R variable y
Write y.toJSON().%ToJSON()
It is advised to wrap all ObjectScript code in a try catch block. More test cases and usages can be found in class R.Test
.
R.Demo
package.pima-diabetes.csv
to class R.Demo.Pima
.Do ##class(R.Demo.Pima).LogReg()
. This will use pima dataset to train and save a logistic regression model.Do ##class(R.Demo.Pima).ScoreDataset()
. This will score the pima dataset using the previously saved model and save the results to the table.