The R tool is a code editor for users of R, an open-source code base used for statistical and predictive analysis. Proficiency in R scripting is recommended before using this tool.
This tool is on the Alteryx Analytics Gallery list of prohibited tools. Apply for an exemption to publish a workflow with this tool.
Designer reads in valid R script and passes the script through the tool. Output from the R tool matches R outputs.
Alteryx does not support custom R code.
Alteryx uses [AlteryxFullUpdate], a global variable for the R script, for metainfo updates. Full metainfo updates occur when AlteryxFullUpdate = TRUE. This happens when the workflow is first opened and when the workflow is refreshed using F5.
AlteryxFullUpdate = FALSE during all other updates, such as a workflow being run or tool reconfiguration. To force full updates after modifying a workflow, select Run script when refreshed (F5).
Update operations cannot be canceled once started.
Standard read and write functions cannot be used when AlteryxFullUpdate = TRUE. If functions such as read.Alteryx or write.Alteryx are in the script when AlteryxFullUpdate = TRUE, an error occurs.
Metainfo passed to outputs when AlteryxFullUpdate = FALSE may differ from metainfo generated when the workflow is run. This can cause errors to occur.
The R tool accepts multiple inputs and labels them in order of connection as #1, #2, and so on. The tool outputs up to 5 data streams from its anchors, labeled 1 through 5. References in the code should follow the same format differences between inputs and outputs.
For the following descriptions, #1 refers to any input connection label and 5 refers to any output anchor.
The R tool outputs using the function write.Alteryx(dataVariableToWrite, 5).
Insert Code: A list of Alteryx-specific commands that can be injected into the R code editor. The commands are intended to be used with typical R commands. This list is not comprehensive.
To access interface tools with the R tool, enter %Question.tool_name% where tool_name is the name of the interface tool, which can be found on the Annotation tab in the Configuration window
Read Input: A function that reads in a connected data input. Each connected input creates a separate option listed in order of connection. Select a listed input to insert the connection into the Code Editor. This function can be used regardless of whether AlteryxFullUpdate is TRUE or FALSE.
The read.Alteryx() function streams input data into the R environment.
Row Names: An optional parameter to include a new column titled RowNames, populated with the first column of data to be treated as row headers. By default, this parameter is set to FALSE.
write.Alteryx(dataVariableToWrite, 5, TRUE)
as Data Frame: Option used to read in a data table. No additional parameters.
read.Alteryx("#1",mode="data.frame")
as Data Frame: Chunked: Option used to read in a large data table. Specify the number of records processed at a time.
read.Alteryx("#1", 50000, mode="data.frame")
as List: Option used to read in spatial objects.
read.Alteryx("#1", mode="list")
as List: Chunked: Option used to read in a large number of spatial records. Specify the number of records processed at a time.
read.Alteryx("#1", 50000, mode="list")
Input MetaInfo: Option used to read in the metainfo from the input rather than the data. The function returns a data.frame containing the metainfo. The rows of the data.frame represent each column from the input data, while the applicable metainfo is displayed in 6 columns:
read.AlteryxMetaInfo("#1")
Set Progress: A function that reports progress on the tool icon in a running workflow. Select one of the increment options:
AlteryxProgress(0.25)
Output Message: A function that displays a message in the Results window. The message priority determines when the message is reported.
See Workflow Configuration to change message display behavior.
AlteryxMessage("message", msg.consts$INFO, priority.consts$LOW)
AlteryxMessage("message", msg.consts$INFO, priority.consts$LOW, 5)
AlteryxMessage("message", msg.consts$WARNING, priority.consts$MEDIUM)
AlteryxMessage("message", msg.consts$FIELD_CONVERSION_ERROR)
AlteryxMessage("message", msg.consts$ERROR, priority.consts$HIGH)
Write Output: An option to output a data stream from an output anchor. All anchors can produce data or a graph.
Each output can only produce either data or a single graph.
Source: An optional parameter to add a string to the Source column in the metadata output.
write.Alteryx(dataVariableToWrite, 5, source="customer data from 2012 repo")
Row Names: An optional parameter to include a new column titled RowNames, populated with the first column of data as row headers. By default, this parameter is set to FALSE.
write.Alteryx(dataVariableToWrite, 5, TRUE)
Extra files that accompany the R Code will not automatically be detected as workflow dependencies. Therefore, if you need to package your workflow and your R code has its own dependencies, be sure to include any additional files using Tool Configuration in the Configuration window.
Create Graph: An option to output a graph of the analysis. The output is treated as a reporting snippet that can be read by Reporting tools. Select one of the graph size options:
AlteryxGraph(5, width=576, height=576)
xPoints <- c(1,2,3,4)
yPoints <- c(2,4,6,8)
plot(xPoints, yPoints)
invisible(dev.off())
if(AlteryxFullUpdate)...: A function that works with the global variable [AlteryxFullUpdate].
write.AlteryxAddFieldMetaInfo: A function that adds the metainfo from a single column to the named output. This function cannot be used when AlteryxFullUpdate = FALSE.
Any combination of the following parameters may be used.
nOutput: The output to which the column's metadata is added.
name: The column name whose metainfo is output. This option verifies that the provided name is valid or an error occurs.
fieldType: A string representing the column's datatype. This option verifies that the provided fieldType is valid or an error occurs. Size and Scale may need to be manually updated depending on the fieldType. Several fieldTypes are accepted entries that are converted to valid Field types.
size: The size of the column.
Many fieldTypes are assigned a value automatically.
scale: The number of decimal places for column values.
This option is required for FixedDecimal fieldTypes, but is ignored by all other fieldTypes.
Valid FieldType strings | Size overridden | Scale overridden | Converts to valid FieldType |
---|---|---|---|
Bool | automatic | logical | |
Byte | automatic | ||
Int16 | automatic | ||
Int32 | automatic | integer | |
Int 64 | automatic | ||
FixedDecimal | manual | manual | |
Float | automatic | ||
Double | automatic | numeric | |
String |
manual | ||
WString | manual | ||
V_String | |||
V_WString | factor; character | ||
Date | automatic | ||
Time | automatic | ||
DateTime | automatic | ||
Blob | |||
Spatial Object |
source: An optional column that can be populated with a string describing the column's origins.
description: An optional column that can be populated with a description string.
write.AlteryxGraphMetaInfo: A function that sets the metainfo of the named output to an R Script Graph by calling the function AlteryxGraph(). This function cannot be used when AlteryxFullUpdate = FALSE.
nOutput: The output to which the column's metadata is added.
©2018 Alteryx, Inc., all rights reserved. Allocate®, Alteryx®, Guzzler®, and Solocast® are registered trademarks of Alteryx, Inc.