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

腳本Re: 如何快速計算列值>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");