I would like to use the currentInteration variable within a R-Script. For "standard" variable it seems to be something like
x <- "FLOWVAR(Name_of_the_variable)"
With currentIteration it does not work in the same manner.
Any hint for me???
Best regards, Jürgen
PS: R-Scripting is a very good approach, but I have not found a way to "get rid off" one file with all templates....(It would be nice to have one file per template)
I'm not sure I follow your problem. For me the currentIteration flow variable is readilly avaiable within the R-snippet as $${IcurrentIteration}$$ (selectable from the flow variable list on the left hand side in the R-snippet dialog/config box). This is reffering to the R->Local->R Snippet (Local) node.
Are you using the R snippet from the R node collection or from the 'community node' colleciton?
indeed, the handling of the flow variables in the R Scripting Integration (community contributions) is different from KNIME's R integration (then one Paul was mentioning).
I think you did it already the right way, but be aware that in the case you are mentioning x will be a string! If you what it to be a number (currentIteration is Integer) leave the quotes away.
➤FLOWVAR(name of flow variable) will be replaced by the value of the flow variable
➤Var_string = apple
“FLOWVAR(Var_string)” = “apple”
Concerning your "PS:" you can define as many template file as you want in the preferences, enable and disable them. For us it seemed more convinient to have all template in one file. Here is another hint: if you use the category in the header of your template, your templates appear sorted into "folders".
########################################################################################
# name: a nice plot
# author: your name here
# category: folder/subfolder/subsubfolder
# preview: plotpicture.png
how many columns does you input table have and how many iterations do you want to run? does it fail in the first iteration? could you try to use the openInR node and replace the flow variable with the current value to see whether this succeeds?
PS: R-Scripting is a very good approach, but I have not found a way to "get rid off" one file with all templates....(It would be nice to have one file per template)
You could write a script to combine templates from individual files, if you prefer having them separate. To make it easier to work with the single templates file, I created a couple of small scripts.
One extracts templates by name. I use this to append an appropriate 'template' to my snippets file when creating a new one.
The other rearranges templates in my file based on a sorted list of template names.