いくつかの重要な列をグループ化した後、残りの列を「屋根裏部屋」に非表示にします。
グループ化されていないすべての列のリストを取得するにはどうすればよいですか?
すべての列のリストを取得し、グループ化された列のリストを取得し、グループ化された列を列のリストから削除します。
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);
文字列を経由した迂回は意味があります:)
なぜそれが必要なのか疑問に思います...
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}
知っておくべき重要な詳細:
- << group columnsの戻り値は列グループではなく文字列です。
<< get column group returns a list of columns, not a column group
- 重要: この列リストには、先頭に「:」が付いた名前がリストされます。
- compare: get column names() は先頭の ":" を除いた名前のリストを返します。
- -> 2つのリストは互いに互換性がありません
回避策:
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};
列を扱う際に私が唯一気にしているのは、すべてを文字列にすることです。そうすることで、そうしないと発生するであろう膨大な問題を回避できます。私の意見では、文字列から他の「列形式」に移行できるため、最初から文字列以外の形式で列を扱おうとする理由は基本的にありません。また、文字列以外の形式から始める必要があるとしても、私の経験上、それは無駄です。