如何快速計算> 2的列總數?計算似乎很簡單,但是我沒有快速的方法:
計算每列中> 2的總數,並獲得新表。
謝謝!
dt = Open( "$SAMPLE_DATA\Data\Missing Data Pattern.jmp" );

腳本編寫回复:如何快速計算> 2的列總數?請找到一種方法(無疑有很多方法)。 使用“幫助>腳本編制索引”確定其工作原理以及如何對其進行改進。
NamesDefaultToHere(1);
// Make a table with some (integer) values
nr = 10;
nc = 5;
dt = AsTable(J(nr, nc, RandomInteger(1, 5)));
dt << setName("Integers Between 1 and 5");
// Start here . . .
dt = CurrentDataTable();
// Get the data into a matrix
m = dt << getAsMatrix;
// Only keep values above the threshold (of 2)
m[Loc(m <= 2)] = .;
// Set all remaining values to 1
m =!IsMissing(m);
// Sum every column, and make a table
dt2 = AsTable(VSum(m));
dt2 << setName("Number of Values Above 2");