如何建立公式列以查找幾列中的最大值<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)