You can use the R source node to run an R script that will generated table outputs than can then be connected directly to a target node, or to tables from another source to create a data mashup.
There are a few ways in which to construct your R script: they can be downloaded from the Pyramid Marketplace, imported from the Pyramid content manager, or written or pasted directly to the R node's Properties panel.
Configure the R Source
Add the R source node to the data from and then go to its Properties panel to configure the script.
There are three ways in which you can provide the R script:
- Marketplace: download a script from the Pyramid Marketplace (red arrow above). Once downloaded, the script will appear in the script window.
- Pick a Script: open the content manager folder tree to select a script that was built and saved in Pyramid (green arrow above). Once the script is selected, it will appear in the script window.
- Write or Paste a Script: write or paste a script directly into the script window.
Choose the managed R environment (blue highlight above) that uses the required R version and packages.
Pyramid enables Admins to create multiple virtual environments, where each of these environments can use a different R version and different 3rd party packages.
View the list of packages that have been downloaded to the currently selected virtual R environment (yellow highlight above).
- Click here to learn more about virtual scripting environments.
Configure the Output
The Output window displays the output of the current script. Each row in the listing represents a column:
- Data Frame: the data frame of the column.
- Column Name: the name of the column.
- Type: the data type of the columns.
- Size: the size of the column
To edit a column output, click on it to open its fly-out menu (green arrow below). To delete a column, click its delete icon, and to add a column, click the plus icon.
When downloading a Marketplace script, Pyramid detects the output automatically. When writing your own script, or selecting a shared script, users must manually add the output columns to the Output window.
Click 'Auto Detect' from the Output window to open the 'Auto-detect output columns' dialog, where you can enter the data frame. Pyramid will then detect the given data frame and its columns in the script, and add them to the output list.
- Click here to learn more about data frame support.
To add columns to the output list manually, click the plus icon (green arrow below). You need to specify the data frame, column name, and data type.
- Click here to learn more about the Select functions.
In this example, the Iris Data script is downloaded from the Pyramid Marketplace to import the data set and convert it to a table.
As soon as the script is downloaded, it's added to the script window. We can see here the data frame and columns names (purple highlight below), which correspond to the output listing (yellow highlight):
Next, the new table was connected to the source node by clicking the Add Table button:
When the new Dates table is previewed, we see the table and columns that were generated by the script: