cumulating / looping values in a column over all rows

Dear KNIME community,

I wonder how to cumulate gradually all values in a column over all rows. Something like the REATIN-Statement in a SAS data step or some simple loop like

for i = 2 to numberOfRows

col(i) = col(i) + col(i-1)

next i

would be quite nice.

I tried with chunkloop or TableRowToVariable-Lopp and a global variable for retaining last iterations values, I also tried with your nice lag-Operator, but everything I got is wrong and far to slow.

Do you have any better idea than me during the last helpless hours?

Thak's a lot in advance,

cheers, Martin

 

Hi Martin,

have you tried an R snippet in which you use the cumsum command?

I think it may work 

Giovanni

Hi Martin,

you can solve this with the Java Snippet. Create a custom variable for the previous result and add the current value to it.

// Your custom variables:
double prev = 0;

// Enter your code here:
prev += c_Counter;
out_Counter = prev;

If you want to loop this, btw, you need the recursive loops, we have a youtube video about them: https://www.youtube.com/watch?v=TdtljHyIGJA


Cheers, Iris

PS: or, if you can, wait for 2.10 :-)

Hi Giovanni, Hi Iris,

thanks for your hints! cumsum sounds funny - and runs consirably faster than my poor experiments with loops and recursions. I think I have to deal a bit with R in KNIME. I'm looking foreward for 2.10!

regards from Bonn,

Martin