如何選擇基於一個(第一)列相同但基於另一列不同的行大家好。
我正在嘗試制定一個腳本(JMP 13),該腳本將允許我隔離基於一列相同但基於另一列不同的記錄(行)。更詳細地說,我對同一樣本進行了兩次觀察/測量,但對於某些樣本,結果不同。我如何隔離這些案例?我已經嘗試過這個(我可能錯過了一些非常基本的東西 - 抱歉:(
// Assume the columns are "ColumnA" and "ColumnB"
dt = Current Data Table(); // Reference the current data table
// Loop through each row and compare values in the specified columns
For(i = 1, i <= N Row(dt), i++,
// Compare with every other row to find matches on ColumnA but differences on ColumnB
For(j = i + 1, j <= N Row(dt), j++,
If(dt:ColumnA[i] == dt:ColumnA[j] & dt:ColumnB[i] != dt:ColumnB[j],
dt << Select Row(i);
dt << Select Row(j);
)
)
);
對於這個問題的幫助將不勝感激。
自動化和腳本編寫回覆:如何選擇基於一個(第一)列相同但基於另一列不同的行太棒了,非常感謝吉姆。
回覆:如何選擇基於一個(第一)列相同但基於另一列不同的行功能
dt << 選擇其中()
將一次性選擇所有與指定條件相符的行,這將消除第二個 For() 迴圈。它也會更有效率。下面是一個例子
Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
For Each Row(
currHt = :height[Row()];
currWt = :weight[Row()];
dt << select where( :height == currHt & :weight != currWt, current selection( "extend" ) );
);