I know I said I would revert back to IronPython posts. But, I had to do a bit of TERR work this week that I thought users might find helpful. Now, my use case was fairly complex, but the root of it was simply adding calculated columns to a table in TERR by applying the “within” R function.
Before I get started, note that this is a simplified example. You may look at this demonstration and wonder why I didn’t use a calculated column. I had good reasons for performing this task in TERR. To demonstrate the “within” function, I created a simpler example.
Here is my original table. I need to add a BOE calculation to this table.
Using the Within Function
Here is my TERR script. The script performs three steps.
- Create an object called mytable that is equal to my input parameter.
- Create a new calculated column called BOE. Note, I lead with the table/object name and denote the column with “$”.
- Build a new object called mytable2. The within function adds the new column to mytable. Mytable2 is my output parameter.
After writing the script, I setup my input and output parameters.
I only have one input parameter (Type = table).
I have one output parameter (Type = table) called mytable2.
With the script, input parameters, and output parameters complete, I can run the data function and map my columns to the parameters. This was the result.
The “within” function allows the user to easily append an existing table.
Now, you know how to add calculated columns with TERR.
Content created with Spotfire 10.2.