After grouping several important columns, I want to hide the remaining columns in the "attic".
How do I get a list of all non-grouped columns?
Get list of all columns, get list of grouped columns and drop grouped from the list of columns
Names Default To Here(1); // Setup dt = Open("$SAMPLE_DATA/Cities.jmp"); dt << group columns("xy", {:X, :y}); dt << group columns("pollutants", :Ozone :: :Lead); collist = dt << Get Column Names("String"); grouped_list = {}; For Each({groupname}, dt << get column groups names, c = dt << get column group(groupname); groupcols = Transform Each({cr}, c, cr << get name); Insert Into(grouped_list, groupcols); ); nongrouped = Set Difference(collist, grouped_list); For Each({colname}, nongrouped, Column(dt, colname) << Hide(1); ); wait(0);
The detour via strings makes sense : )I wonder why is it necessary ...
Names Default To Here(1); // Setup dt = Open("$SAMPLE_DATA/Big Class.jmp"); dd= dt << group columns("xy", {:X, :y}); ee= dt << group columns("pollutants", :Ozone :: :Lead); Type(ee) collist = dt << Get Column Names(); grouped_list = {}; groups= dt << get column groups names; For Each({groupname},groups, groupcols= dt << get column group(groupname); Insert Into(grouped_list, groupcols); ); Show(grouped_list); // list of names with ":" {:OZONE, :CO, :SO2, :NO, :PM10, :Lead, :X, :Y}; show(collist);// list of names without ":" {city, Latitude, Longitude, ... } nongrouped = Set Difference(collist, grouped_list); // ?!?! {city, CO, Latitude, Lead, Longitude, Max deg. F Jan, NO, OZONE, PM10, POP,"pop- m"n, Region, SO2, State, X, Y}
details which are important to know:
<< get column group
Workarounds:
convert to list of columns = Function ({myColList}, Transform each({col},myColList, Name Expr(As column(dt, col))) ); grouped_list = convert to list of columns(grouped_list); // looks like before, but is something completely different collist = convert to list of columns(collist); //{:city, :Latitude, :Longitude, ... } nongrouped = Set Difference(collist, grouped_list); Show (nongrouped) // {:city, :Latitude, :Longitude, :Max deg. F Jan, :POP, :"pop- m"n, :Region, :State};
When I'm dealing with columns, only thing I care about is to get them all to strings as it will avoid a massive amount of issues you will have otherwise. In my opinion, there are basically zero reason to try and deal with columns initially with anything else than strings as you can always go from string to other "column formats". And, if there is a reason to start from something else than a string, it isn't worth it in my experience.