Related to this wish list item I created: Add normalization and robust statistical functions (and matrix functions) . I thought I could just try to write these as custom functions for now (even though I know it will be impossible to share them and have them updated for everyone), but I faced my first problem almost immediately: how to reference columns... When using Custom Formulas am I stuck using row-level calculations or referencing columns as strings instead of :colname which would prevent me from using them directly from Formula Editor.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
my_min = New Custom Function(
"custom",
"My Min1",
Function({x, y},
As Constant(
vals = Column(x) << get values;
groups = Column(y) << get values;
);
cur_group = Loc(groups, As Column(y));
vals[cur_group[Loc Min(vals[cur_group])]];
),
<< Formula Category("Statistical")
);
Add Custom Functions(my_min);
my_min = New Custom Function(
"custom",
"My Min2",
Function({x, y},
Col Minimum(Column(x), Column(y));
),
<< Formula Category("Statistical")
);
Add Custom Functions(my_min);
my_min = New Custom Function(
"custom",
"My Min3",
Function({x, y},
Col Minimum(x, y);
),
<< Formula Category("Statistical")
);
Add Custom Functions(my_min);
dt << New Column("ColMin", Numeric, Continuous, Formula(Col Minimum(:height, :sex)));
dt << New Column("MyMin1_str", Numeric, Continuous, Formula(custom:My Min1("height", "sex")));
dt << New Column("MyMin2_str", Numeric, Continuous, Formula(custom:My Min2("height", "sex")));
dt << New Column("MyMin3_str", Numeric, Continuous, Formula(custom:My Min3("height", "sex")));
dt << New Column("MyMin1_ref", Numeric, Continuous, Formula(custom:My Min1(:height, :sex)));
dt << New Column("MyMin2_ref", Numeric, Continuous, Formula(custom:My Min2(:height, :sex)));
dt << New Column("MyMin3_ref", Numeric, Continuous, Formula(custom:My Min3(:height, :sex)));
-Jarmo