Hi Jarmo,
I like this solution a lot (Thanks also Jim for the suggestion).
One thing I need to take in account is the fact that I might have multiple dozen of factors.
Is there a way to force a fixed height for Table Box() ?
For instance, only 5 visible row and the ability to scroll down to have a fixed height in order to add more user inputs (radio box, check box, etc...).
Below an example of Table Box () with more rows and all of them are visible (it will become an issue with much more factors)
Thanks a lot
Names Default To Here(1);
dt = New Table("RawData",
Add Rows(20),
New Column("factor1",
Character,
set values({"A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C", "C", "C"})
),
New Column("factor2",
Character,
set values(
{"T0", "DROP1", "DROP2", "DROP3", "DROP4", "DROP5", "DROP6", "T0", "DROP1", "DROP2", "DROP3", "DROP4", "DROP5", "T0", "DROP1", "DROP2",
"DROP3", "DROP4", "DROP5", "DROP6"}
)
),
New Column("factor3", Character, set values({"1", "1", "1", "2", "2", "", , "", "", "", "", "", "", "3", "3", "3", "3"})),
New Column("factor4", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor5", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor6", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor7", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor8", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor9", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor10", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor12", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor13", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factorA", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factorB", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factorB1", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factorC", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factorD", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor69", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor67", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor47", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"})),
New Column("factor56", Character, set values({"a", "a", "a", "", "", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b"}))
);
cols = dt << get column names("character", "string");
factors = {};
factor_counts = {};
missing_perc = {};
For Each({colname}, cols,
Summarize(dt, uniq = by(Eval(colname)));
Remove From(uniq, Contains(uniq, ""));
nvalues = Col Number(Column(dt, colname));
Insert Into(factors, colname);
Insert Into(factor_counts, N Items(uniq));
Insert Into(missing_perc, (nvalues)/ N Rows(dt));
);
dt_factors = New Table("Demo",
Add Rows(N Items(factors)),
New Column("Factor", Character, Nominal, Values(factors)),
New Column("Count", Numeric, Continuous, Values(factor_counts)),
New Column("% Non-missing", Numeric, Continuous, Format("Percent", 12, 3), Values(missing_perc)),
Invisible
);
orange_rows = dt_factors << Get Rows Where(:"% Non-missing"n < 0.5);
yellow_rows = dt_factors << Get Rows Where(0.5 < :"% Non-missing"n < 0.9);
For Each({colname}, dt_factors << Get Column Names("String"),
Column(dt_factors, colname) << Color Cells("Green");
Column(dt_factors, colname) << Color Cells("Orange", orange_rows);
Column(dt_factors, colname) << Color Cells("Yellow", yellow_rows);
);
nw = New Window("Select",
H List Box(
Panel Box("Select factors to run the analysis",
bb = dt_factors << get as report
),
Panel Box("Actions",
Lineup Box(N Col(1),
Button Box("OK",
tb = bb << child;
sel_rows = tb << get selected rows;
show(sel_rows, tb[1][sel_rows]);
),
Button Box("Cancel", << Set Function(function({this}, this << close window))),
)
)
)
);
Close(dt_factors, no save);