Calling R Inline in a Report or ETL Script
Any R expression can be executed inline within a BQL query or ETL statement.
You can do this in a report by using REXP in a column expression. REXP
contains two fields: the first determines the expected return type (Birst will cast the results to
that type) and the second is the R expression to run.
Prior to calling R in a report, a session variable is required to instantiate
the model. See Setting
Up Sessions with R Initializers.
To call R inline in a report
|
1.
|
Open the report
in Designer. For example, a report on car data:
![](../../../Images/Connectors/RServer/image1445.gif) |
|
2.
|
Add a column
to this report that calls R to utilize a pre-created model to predict
the speed of a car based on the stopping distance (model<-lm(formula=speed~dist,cars).
Add a column to your report (you can add a second instance of a column
you are already using) then click the column header and select Column
Properties. |
|
3.
|
Reference
R in the Expression using REXP. In the example below, the expression references
a metric to predict the estimated speed of a car based on stopping distance.
![](../../../Images/Connectors/RServer/image1444.gif) |
|
4.
|
Click Save
in the dialog box. For example, this is the resulting report:
![](../../../Images/Connectors/RServer/image1446.gif) |