Execute Custom R Code - campsych/concerto-platform GitHub Wiki

Each node in your test logic flowchart is a separate sub-test. To create a node, you can either:

  • create a new Test and add it as a node to flowchart
  • use the eval node, which lets you execute code without the need to create a dedicated test containing that code

Aim

We want to execute custom R code without creating a dedicated test containing it. In practice you might be using the eval node to perform some more complex scoring or to run some specialised R functions that are not available through existing nodes. In this guide the sole purpose of the node will be to print out “Hello world!” a text string.
We should see something similar to this in our browser console:

The above is taken from Chrome’s browser console (in Chrome: click F12 to start developer tools, and go to console tab).

Walkthrough

  1. Add eval node
    Right click anywhere in the flowchart area and select the eval node from the dropdown.
  2. Edit Code param
    To edit Code param, click on its edit icon.
  3. Enter R code
    Now you need to enter the R code that you want to execute in this node. See below for an example of R code which in this case will be used to print out “Hello world!”. When done, remember to Save all your changes.
  4. Connect eval node
    For our eval node to be executed, we need to connect it to the execution flow. To do this, drag the connection from test start execution out port to eval node execution in port.
  5. Debug test
    Click Debug test in the bottom-right corner of the screen. The difference between running a test in debug mode as opposed to regular mode (through Run test button), is that in debug mode, your test logic output will be exposed in your browser console. This is useful for us here, as we want to see results of our code execution.
⚠️ **GitHub.com Fallback** ⚠️