Creating flow variables with an R Snippet

Hi,

I am new to Knime and I saw this previous post but could not get it to work.  When ever I applied this syntax to my R snippet, the flow variable does not get created (I checked the Node Monitor as well as the Flow Variable list). 

I would assume the following code should create a flow variable named "new" with a value of "Testing", but nothing seems to get created

knime.flow.out <- list(new = "Testing")

Any ideas on how to create flow variables via an R snippet?  Has the syntax changed? Am I just missing something really simple here?

Thanks!

No, it is working for me as expected. Did you execute the node? The flow variables are created during execution.

Best, Iris

Thanks for the reply Iris.  Yes I have tried executing the node (which completed and has the green light), but the flow variable still does not get created.  Is there any other configuration that needs to happen?  Any other R code that needs to be added in conjunction?

Could you maybe post me a minimal workflow where it is not working for you and I check what is not working?

Best, Iris
 

Hi Iris,
Thanks so much for offering to help! much appreciated! I'm not sure how to export the workflow properly, so thought I would do screenshots.  Hope that is ok. I basically just have issue with the R snippet node creating a flow variable. Ideally I want to use this newly created, flow variable in subsequent nodes, such as the Case Switch Data (Start)

Here is what the config looks like for my R Snippet after running "Eval Script". As you can see my R script hardly has anything, just want to create a flow variable for now (but will obviously add more for my actual script). Notice flow variable list is not updated

Then when double clicking on knime.flow.out to print the variable I see this, which to me makes it seem like I'm on the right track? however the flow variable list is still not reflecting it.

After executing the node (one of the things you wanted to confirm) the flow variable list still only shows the same three flow variables I started with, but does not show the one for "new". Thus I am not able to utilize this variable in any downstream nodes, because it doesn't seem to exist.

Sorry for the "low tech" info, but hope this gets to what I am attempting to do. Let me know if you need more info.

thanks again!

Hi,

The flow variable list in the R Snippet node only shows flow variables available prior to executing the node. This means that the newly created flow variable will only be available at the R Snippet outport.

To check this, right click R Snippet, select Data Output, then go to the Flow Variables tab. Since everything else seems to be working, I would assume that you will find the flow variable there :)

Hope that helps!

Cheers,

Roland

Hi Roland,

 

Thanks for the info. I did check the data output and the flow variable is still not there (and also not selectable for downstream nodes).  I'm using El Captian on a Mac.  Is there incompatibility w Macs or my OS?

 

Thanks,
Brian

 

Hi all,

I was able to try the same code on a Windows machine and it works fine.  So something is preventing this from working on my Mac (the OS or my Mac version of Knime or R version).   i will keep investigating and report back if I find out something.  If anyone knows how to get this to work on a Mac, please let me know.


thanks,
Brian

Hi all,

In case anyone else runs into this, I was able to find the solution.  I had to upgrade to KNIME 3.2 (apparently there was a bug in 3.1 that prevented this from working) and now I am able to create flow variables using an R snippet. Thanks again to all those who replied earlier