missing values: last value carried forward

i have a matrix like this:

A   Z   2010

?   ?   2011

?   ?   2012

in R there is a function na.locf [last observation carried forward] [package: zoo] that takes the last available value and copies them down over the NA values. the result is like this:

A   Z  2010

A   Z  2011

A   Z  2012

is there a way to do something similar in KNIME [without using a R node?]

henk

Hi Henk,

You can use the Java Snippet node if you are familiar with Java. You can keep the last not missing value and set that as the new value for the missing cells in columns. Although it is not flexible in a sense (as I know), that you have to set the columns for output in advance.

Hope this helps, gabor

For no-Java friendly people like me, i attach below the java snippet code that handles the above data issue:

 

// system variables
public class JSnippet extends AbstractJSnippet {
  // Fields for input columns
/** Input column: "String 1" */
  public String c_String1;
/** Input column: "String 2" */
  public String c_String2;

  // Fields for output columns
/** Output column: "String 1" */
  public String out_String1;
/** Output column: "String 2" */
  public String out_String2;
/** Output column: "New Col" */
  public String out_NewCol;

// Your custom variables:
String txt="";
String txt2="";
// expression start
  public void snippet() throws TypeException, ColumnException, Abort {
// Enter your code here:

if( c_String1 != null ) {
 txt = c_String1;
}

if( c_String2 != null ) {
 txt2 = c_String2;
}

out_String1 = txt;
out_String2 = txt2;

For even less Java friendly people like myself, why not use the "Time Series Missing Value" node and choose the option Last.

Thats all there is to it :-)

 

Simon.