Here is one way to handle this
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 5 ),
New Column( "a",
Character,
"Nominal",
Set Values( {"Positive", "Positive", "Negative", "Negative", "unknown"} )
),
New Column( "b",
Character,
"Nominal",
Set Values( {"TRUE", "FALSE", "TRUE", "FALSE", ""} )
)
);
my_function = Function( {name, col1, col2},
dt << New Column( name, Character );
Eval(
Eval Expr(
Column( dt, name ) << Set Formula(
If(
as Column( Expr( col1 ) ) == "Positive" & as Column( Expr( col2 ) )
== "TRUE", "True Positive",
as Column( Expr( col1 ) ) == "Negative" & as Column( Expr( col2 ) )
== "TRUE", "False Positive",
as Column( Expr( col1 ) ) == "Negative" & as Column( Expr( col2 ) )
== "FALSE", "True Negative",
as Column( Expr( col1 ) ) == "Positive" & as Column( Expr( col2 ) )
== "FALSE", "False Negative",
"?"
)
)
)
);
);
my_function( "new column", "a", "b" );
Jim