あ質問列名のセットの使用について。 JSL の連想配列を使用して集合演算を実行できます。 メソッド <
// make three sets
rgb = associativearray({"red","green","blue"});
cmy = associativearray({"cyan","magenta","yellow"});
bw = associativearray({"black","white"});
// join them together
all = rgb;
all<<INSERT></INSERT>
問題は、列名のセットに関して提起されました。この例では、連想配列の集合操作を使用しています。 <<削除すべての列のセットと文字「i」を含む列のセットとの差を取得します。
// keep only the columns with an "i" in the name
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
allnames = dt << getcolumnnames( "string" );
inames = {};
For( i = 1, i <= N Items( allnames ), i++,
If( Contains( allnames[i], "i" ),
Insert Into( inames, allnames[i] )
)
);
allset = Associative Array( allnames ); // {"name", "age", "sex", "height", "weight"}
iset = Associative Array( inames ); // {"height", "weight"}
allset << Remove( iset ); // the "not i" set...
notinames = allset<<GETKEYS></GETKEYS>
これはすごく素敵。このような連想配列を使用することは考えていませんでした。過去にオブジェクト参照のリストを使用したことがあり、リストを検索して特定の条件を満たすオブジェクトを除外したいと考えていました。リスト操作の使用は非常に遅く、制御ロジックは複雑でした。これにより、どのように簡単になるかがわかります。サンプル コードをコピーして貼り付け、今後の参照用に「JSL コレクション」に追加します。