我一直在尝试从 JMP 表中提取第二大数字。 到目前为止,我只是手动使用
降序排序( Eval List( {:X1, :X2, :X3}));
我怎样才能只传递整个表而不是单个列名?

IF() 函数中的比较组件存在逻辑问题。
If( (Abs( colMax )) > 300 | (Abs( colMax )) > 250
任何大于 250 的值都将使比较为真,因此,不需要 >300。
比较只需要:
If( ( Abs( colMax ) > 250,
你问为什么你得到 193 的值?这是因为打印出来的值是该列的第二高值,并且您的过滤基于该列中的最大值。第二高的值可以是任何值。如果您在一列中有以下值
最大列值为 600,因此它将通过 Max Col() > 250 的 IF() 子句,列中的第二高值为 193
关于你关于“如何找到第二高值的行号,即 colSecondMaxValues?”,执行此操作的方法已经在脚本中。该声明
maxRows = dt << get rows where( As Column( dt, colNamesList[i] ) == colMax );
返回列中具有最大值的行的行号矩阵。如果您想要第二个最大值的行号,您只需要获取它们等于第二个最大值的行。因此,如果您在 Insert Into() 函数之后添加此语句,您将获得具有第二高值的行
Show(
dt << get rows where(
As Column( dt, colNamesList[i] ) == Col Max( Column( dt, colNamesList[i] ) )
)
);
这是完整的代码
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
colNamesList = dt << get column names( string, continuous, numeric );
colSecondMaxValues = {};
// Loop across all continuous columns and find the Max value in
// a column, delete that value, and then find the second max value
// finally, replace the old values, and save the results
For( i = 1, i <= N Items( colNamesList ), i++,
colMax = Col Max( Column( dt, colNamesList[i] ) );
If( Abs( colMax ) > 250,
maxRows = dt << get rows where( As Column( dt, colNamesList[i] ) == colMax );
Show( maxRows );
Column( dt, colNamesList[i] )[maxRows] = .;
Insert Into( colSecondMaxValues, Col Max( Column( dt, colNamesList[i] ) ) );
Show(
dt << get rows where(
As Column( dt, colNamesList[i] ) == Col Max( Column( dt, colNamesList[i] ) )
)
);
Show( colSecondMaxValues );
Column( dt, colNamesList[i] )[maxRows] = colMax;
);
);@txnelson谢谢你的剧本。 我正在尝试为此脚本设置大于 300 或 250 的条件,但我无法理解为什么它仍然需要像 193 这样的值。 另外,如何找到第二高值的行号,即 colSecondMaxValues? 非常感谢您的帮助。
dt=open("$SAMPLE_DATA/semiconductor capability.jmp");
colNamesList= dt<<GET column="" names=""> 300 | (abs(colMax)) > 250,
maxRows = dt<<GET rows="" where=""></GET></GET>如果你想要整个表中的第二大值,不管它在哪一列:
Names default to here(1);
dt = open( "$SAMPLE_DATA/semiconductor capability.jmp" );
//Find the two largest values in the entire table
Sort Descending(Shape(dt << Get all columns as matrix(),1))[{1, 2}];
//Or, to exclude character columns
Sort Descending(Shape(dt << Get as matrix(dt << get column names(numeric)),1))[{1, 2}];这是我编写的一个小脚本,用于确定数据表中所有连续列的第二高值
names default to here(1);
dt=open("$SAMPLE_DATA/semiconductor capability.jmp");
colNamesList= dt<<GET column="" names=""></GET>