Creating Flow Variables in R Scripting Nodes

How do you create a flow variable inside of a R scripting node? What is the proper syntax?

I know how to create flow variables in python nodes by using the following syntax

flow_variables["variablename"] = variable

 

However this syntax doesn't work in R even when I change the assignment operator. What is the proper R syntax?

 

 

Hi,

to generate flow variables inside an R-snippet node you can use the following syntax.

For a string type flow variable:

knime.flow.out <- list( varname = "text" ) 

For a double type flow variable:

knime.flow.out <- list( varname = 2.0 ) 

For an integer type flow variable:

knime.flow.out <- list( varname = as.integer(2) ) 

Cheers,
Marco.

1 Like

Thank you so much! I had trouble finding good documentation on how to create flow variables in R. Is there a way to pass multiple values in a vector as a flow variable? This can be done very easily in python nodes, but for some reason in R it will only pass along the first value in the vector I create.

 

Best,

 

Madeline

To my knowledge currently it is not possible to pass a vector back through a flow variable. This said, depdening on the data type, you could render multiple values to a string and then parse it downstream from the R snippet node. Just an idea though.

Cheers,
Marco. 

Thank you so much Marco,

 

I ended up using the Add Table to R node. This allowed me to create a dataframe in python containing all of the metadata associated with the excel files, pass this dataframe into the R node, and then pass the colum values as a vector in the subsequent R node. 

 

Thanks again for your help!

 

Best,

 

Madeline