如何选择基于一列(第一列)相同但基于另一列不同的行大家好。
我正在尝试编写一个脚本 (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" ) );
);