使用 JSL 查找某个条目在列中重复了多少次大家好,
我正在编写一个 jsl 脚本来查找列中重复的字符串条目(即行)。该专栏基本上列出了通常重复的不同测试。
我想要找到的是,如果我可以找到这些行重复的次数,请选择前 N 个重复条目,然后将这些选定的条目插入到列表中,以供图形生成器或制表器分析。
任何帮助表示赞赏。
自动化和脚本编写基础数据分析和建模数据存取回复:使用 JSL 查找列中某个条目重复了多少次这是我将如何处理这个问题
names default to here(1);
dt=current data table();
// Get each different string value and the number of repeated strings
summarize(dt, byGroup = by(:sex), number = count(:height));
show( byGroup, number );
// To find which rows that have the same values
theRows = dt << get rows where( :sex == byGroup[1] );
show(theRows);
回复:使用 JSL 查找列中某个条目重复了多少次您能否提供示例(以及示例的解决方案),以便更容易理解您想要实现的目标,因为我至少想到了三种不同的情况。
回复:使用 JSL 查找列中某个条目重复了多少次谢谢@txnelson的解决方案。这非常适合查找重复的列以及它们重复的次数。我现在遇到的问题是,我试图找到前 N 个(例如:N = 5)重复的字符串并将它们放入列表中以进行进一步评估。我只能找到列表中的顶部项目。
我的问题是,有没有办法找到前 N 个项目,其中 N 可以是任何整数?谢谢!
我修改了代码,如下所示:
names default to here(1);
dt=current data table();
// Get each different string value and the number of repeated strings
summarize(dt, byGroup = by(:Temp_), number = count(:Site));
list = {};
list[1] = 0;
// To find which rows that have the same values
for(i=2, i <N items=""></N>回复:使用 JSL 查找列中某个条目重复了多少次嗨@jthi 。
大类 jmp 数据中的性别列就是一个例子。该列中有F和M,并且重复多次。我想编写一个 jsl 脚本来计算 F 或 M 重复的次数。 @txnelson提供的代码在这种情况下完美运行。这更有意义吗?谢谢
回复:使用 JSL 查找列中某个条目重复了多少次您可以使用 Summarize 查找项目计数,然后查找前 5 个项目,例如,您可以对计数使用 Reverse(Rank()) 并在组中使用找到的索引
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Get each different string value and the number of repeated strings
Summarize(dt, uniq = by(:age), count = Count(:height)); // some column which is numeric to Count
r = Reverse(Rank(count));
top5 = Try(uniq[r][1::5], uniq[r]);
show(uniq, count, top5);