몇 가지 중요한 열을 그룹화한 후, 나머지 열들은 "위쪽"에 숨기고 싶습니다.
그룹화되지 않은 모든 열의 목록을 얻으려면 어떻게 해야 하나요?
모든 열의 목록을 가져오고, 그룹화된 열의 목록을 가져온 다음, 그룹화된 열을 목록에서 제거합니다.
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()는 앞에 붙는 ":"를 제외한 이름 목록을 반환합니다.
- -> 두 목록은 서로 호환되지 않습니다.
해결 방법:
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};
열을 다룰 때 제가 가장 중요하게 생각하는 것은 모든 열을 문자열로 변환하는 것입니다. 그렇게 하면 그렇지 않을 경우 발생할 수 있는 수많은 문제를 예방할 수 있기 때문입니다. 제 생각에는 처음부터 열을 문자열 이외의 형식으로 처리할 이유가 거의 없습니다. 문자열에서 다른 "열 형식"으로 변환하는 것은 언제든 가능하기 때문입니다. 그리고 만약 문자열 이외의 형식으로 시작해야 할 이유가 있다면, 제 경험상 그럴 가치는 없습니다.