使用 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);