R Models

Insight gives the possibility to calculate and create R models based on the data from Insight.

R models in Insight have a similar structure as records.

  1. In Studio, on the Documents Tree, right-click R Models, and select New R Model.
  2. Assign a unique, descriptive name to the new model and click OK.
  3. Map the fields based on which the calculation is based and also the field to be calculated. In the sample screen below, three fields are mapped: Freight, OrderDate, and ShipCountry, which means that these three lines will be pulled from the source record and later used for the R model calculation.

  4. Open the User script tab and create the R script manually. In the sample screen below, the script to calculate the model predicts Freight by ShipCountry. In the script, you can use any mapped field by the field ID.

    • InputData in this script is the data frame with three columns that are mapped on Mapping: Freight, OrderDate, and ShipCountry. In the example, only Freight and ShipCountry are used.
    • OutputModel is the created model.
    Note The OrderDate field that is mapped on the Mapping tab is used for the time filter that you can check and edit under the Filters tab, Time Filter section. You can also add the time/date filter without mapping any time field.
  5. Save the R model.
  6. Open the Tools tab on the toollbar and click Generate R Model.
    The "Select date time interval" window appears.
  7. Define the time interval for generating the R model with the help of calendar controls and click OK.
    The R model is generated and can be used for R functions.