As you can see there are many columns, and I dont want to be writing 10 ifelse statements (there are actually more columns, this is just an example) . Is there a way to pass all the columns as variables to the R node?
The table column to variable takes only 1 column at a time. That would defeat the purpose.
I am ok with using regex or sring matches. For example the new column name would always be $columnname$_max
And the columns that would start with the name Device
If I understand correctly you can use the Extract Column Header – KNIME Hub before using the table row to variable now. This will create a variable for every column that will be Column 0, Column 1… Column n and their values will be the actual Column Name.
If you would like you can even use the Column Combiner – KNIME Hub between the Extract Column Header and the Table Row to Variable nodes to get all of the column names into one variable.
Hi @wkhan
Thank you so much for this information. Now i know how to extract, combine and use the column names as variable. However I guess i was looking for a way to combine all the columns into a variable so that I can loop through them. You did answer my question, so the solution goes to you!
However i found it was easier to do it in R like @gonhaddock suggested.
Thank You!
Hi @gonhaddock. Yes , I ended up using something similar to what you suggested. Doing it in R was much easier in the end without having to create loop and variable nodes.
Thank you for your suggestion!
You are right because the question as stated, was a KNIME question; and it was answered by @wkhan . What wasn’t clear to me, is that you didn’t need all columns as variables, but a variable vector containing all the column names.
Indeed is much easier to do it in R once you have moved into a scripting node. Because R is so efficient that you can save many KNIME nodes with little coding.
I did intentionally disaggregate the following line of code from the loop section, as it by itself replaces the 3 workflow nodes in the one kindly suggested by @wkhan :
You are exactly right! I needed a variable vector that contained all the column names so that I can cycle through them. And I agree! I would prefer to do most of the slicing and dicing using R and python nodes.
Unfortunately KNIME doesn’t play nice with Python ( due to numerous environment issues) and if I use R libraries in my R node, I cant execute my Knime workflow in batch mode for automated executions
This was the reason I was trying to do everything via KNIME. But i decided it was easier to just do it all in R and manually execute my workflow.
I really hope the KNIME developers can rectify this in future versions!
Hi @wkhan
Yes i have used the Conda Environment propagation. The main issue with Python and R is that I cannot execute my workflow in batch mode (via command line)
The command line execute only works if all my nodes are purely KNIME based or if my R node is basic and does not use any libraries.
If i try to execute, via command line, i get an exit error 4. It has something to do with the batchflow execution not being able to run the python and R libraries.