如何创建公式列以查找几列中的最大值<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />我有几列数字数据(请参见下面的示例),我想创建一个公式列来查找各列中每行的最大值。任何帮助,将不胜感激。谢谢你!
值 1 值 2 值 3 最大值(我会将公式放在此列中)
1 9 6 9
2 1 5 5
3 7 4 7
4 2 6 6
回复:如何创建公式列以查找几列中的最大值我不知道为什么,但 txnelsons 代码对我不起作用。
调试后,我必须将最后一行更改为:
namelist[ Loc( as list(maxes`), Max( maxes ) )[1] ];
现在看来有效
回复:如何创建公式列以查找几列中的最大值这是一个显示最大列的列名称的简单示例
Names Default To Here( 1 );
// Open Data Table: semiconductor capability.jmp
// → Data Table( "semiconductor capability" )
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
dt << New Column( "Example",
character,
formula(
If( Row() == 1,
namelist = {"NPN1", "NPN2", "NPN3", "NPN4"}
);
maxes = [];
For( i = 1, i <= N Items( namelist ), i++,
maxes = maxes || Matrix( Column( namelist[i] )[Row()] )
);
If( Row() <= 5,
Show( maxes )
);
namelist[Loc( maxes, Max( maxes ) )[1]];
)
);
回复:如何创建公式列以查找几列中的最大值这可能不符合逻辑,但是什么列公式会导致不是最大列的 ,而是具有最大值的列的 ?TIA
回复:如何创建公式列以查找几列中的最大值@tx尼尔森你是一个巫师! 感谢您的帮助。
回复:如何创建公式列以查找几列中的最大值您为示例编写的语法将不起作用,但是,我从中收集到的是,您想要创建一个新列,其中包含列列表中的最大值。公式中指定的代码,例如
:a * 2 + :p</img>
必须作为公式所需的实际文字字符串输入。在传递到正在创建的新列之前,JMP 不会对公式中的 JSL 进行任何评估。因此,公式一想要使用,就必须充分实现。并且在您的代码中,它需要是动态的,这需要在 JSL 中创建公式语句,然后传递给公式。
下面是一个脚本,显示了执行此操作的一种方法
names default to here(1);
dt = Current Data Table();
// The formula that needs to be passed into the new column JSL needs
// to look like
// Max( :NameA, :UniqueX, :Name bb )
// A literal string of ":NameA, :UniqueX, :Name bb" needs to be created
// and then plugged into the JSL and then executed
// ":NameA, :UniqueX, :Name bb" is just an illustration, what the
// make up of the string needs to be derived from the actual column
// names in the data table
FreqList = dt << get column names( string, numeric );
freqString = "";
// build the JSL in the form that is required for the formula
For( i = 1, i <= N Items( FreqList ), i++,
If(
Contains( FreqList[i], "Unique" ) == 1 |
Contains( FreqList[i], "Name" ) == 1,
If( i==1, delim = "", delim = ",");
freqString = freqString || delim || " :" || FreqList[i]
)
);
// Run the command, passing into the formula the command string developed above
Eval( Parse( "dt << New Column (\!"Freq\!", numeric, Formula( Max( " || freqString || " )));" ) );
回复:如何创建公式列以查找几列中的最大值@tx尼尔森我有个类似的问题。 我想获得多列的最大值。 在我的示例中,我有一个名为 FreqList 的列列表。 我使用类似于的公式创建的,
dt = current data table();
FreqList = dt << get column names( string, numeric );
For( i = N Items( FreqList ), i >= 1, i--,
If( Contains( FreqList[i], "Unique" )== 0,
FreqList= Remove( FreqList, i, 1 ),
Contains( FreqList[i], "Name" )== 0,
FreqList = Remove( FreqList, i, 1 )
)
);
// Then I was thinking something like the following should work,
dt << New Column ("Freq", numeric, Formula(Col Max(FreqList)));我手动执行此操作的方法是创建一个名为“Freq”的新列。 然后创建一个类似 Maximum(:Freq1,:Freq2,:Freq3,FreqN) 的公式,这将创建一个具有基于行的最大频率的新列。
我该如何在 JSL 中执行此操作?
回复:如何创建公式列以查找几列中的最大值提出的问题@adampaulsmith并回答了@pmroz在为结果列定义的公式中使用 Maximum() 函数。该公式将自动循环每一行并应用该公式。因此,不必进行行引用。
但是,如果您在开放式 JSL 中使用它,则可以向列引用添加下标以指示您处理哪一行。
For( theRow = 1, theRow <= 10, theRow++,
:MaxValue[theRow] = Maximum( :Value 1[theRow], :Value 2[theRow], :Value 2[theRow] );
);
请参阅脚本指南中有关 JSL 的文档
帮助==>书籍==>脚本指南
回复:如何创建公式列以查找几列中的最大值如果您想要搜索许多行,是否有一个函数可以选择一系列行,而不是在函数中输入每一行?
回复:如何创建公式列以查找几列中的最大值谢谢! 我知道这一定是简单的事情。
回复:如何创建公式列以查找几列中的最大值这最大值()函数将为您做这件事。
Maximum(:Value 1, :Value 2, :Value 3)