使用包含列名稱和公式的 for 循環創建新列我正在嘗試從現有表創建一個拆分錶,並將新列添加到拆分錶中,每個新列都具有基於拆分列的公式。 然而,代碼創建了新列,但給了我“公式評估錯誤”
dt2 = Current Data Table();
// Create the split data table
dt2 = dt << Split(
Split By( :S ),
Split(
:Name( "Median(data)" )
),
Group( :L, :m, :C, :P, :z, :x ),
Remaining Columns( Drop All ),
Sort by Column Property
);
colname = {"B","C"};
colby = {"A","B"};
// Add new columns to the split data table
For( i = 1, i <= N Items( colname ), i++,
dt2 << New Column( colname[i]||"/"||colby[i],
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( column(colname[i]) / column(colby[i]) )
););自動化和腳本編寫回复:使用帶有列名和公式的 for 循環創建新列JMP 公式定義在定義時不會計算,僅在運行時計算。因此,該公式需要以完全定義的形式呈現給 JMP。
Column( colname[i] ) / Column( colby[i] )
需要提交給 JMP 作為
Column( "B" ) / Column( "A" )
使用替換功能可以根據需要擴展代碼
// Add new columns to the split data table
For( i = 1, i <= N Items( colname ), i++,
Eval(
Substitute(
Expr(
dt2 << New Column( colname[i] || "/" || colby[i],
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Column( __colname__ ) / Column( __colby__ ) )
)
),
Expr( __colname__ ), colname[i],
Expr( __colby__ ), colby[i]
)
)
);回复:使用帶有列名和公式的 for 循環創建新列我仍然遇到同樣的錯誤,如下
Column B/A Formula Interrupted
Cannot convert argument to a number [or matrix] 1 times At rows: 2 Operation: Divide, Column( "B" ) / /*###*/Column( "A" ) /*###*/
Formula evaluation errors have been ignored
Column C/B Formula Interrupted
Cannot convert argument to a number [or matrix] 1 times At rows: 2 Operation: Divide, Column( "C" ) / /*###*/Column( "B" ) /*###*/
Formula evaluation errors have been ignored
回复:使用帶有列名和公式的 for 循環創建新列嘗試將 Column() 函數更改為 As Column() 函數
回复:使用帶有列名和公式的 for 循環創建新列那行得通,謝謝!