A问题关于使用列名集。 您可以使用 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 收藏”以供将来参考!