在列方程中使用數值對象我需要能夠取得一個在迭代函數中遞增或遞減的數值對象,並將其用於列公式中。在下面的等式中,col、l 和 m 的值需要在列公式中求值。我該如何實現這一點? Parse()、Eval() 和 Num() 函數無法正常運作。
For( i = 1, i <=8, i++,
col = 11+i;
l = col - i;
m = col + 1 - i;
colno = Char(col);
New Column("Column "||colno, Character, "Nominal", Formula(If(Row() == 12, Lag(Column(1), l), If(Row() == 13, Lag(Column(2), m), Lag(Column(col, 1)))))));
自動化和腳本回覆:在列方程中使用數字對象這似乎有效。 Eval(Eval Expr(....)) 在建立列之前評估表達式。
For( i = 1, i <= 8, i++,
col = 11 + i;
l = col - i;
m = col + 1 - i;
colno = Char( col );
Eval(
Eval Expr(
New Column( "Column " || Expr( colno ),
Character,
"Nominal",
Formula(
If( Row() == 12,
Lag( Column( 1 ), Expr( l ) ),
If( Row() == 13,
Lag( Column( 2 ), Expr( m ) ),
Lag( Column( Expr( col ), 1 ) )
)
)
)
)
)
);
);
回覆:在列方程中使用數字對象Column( col, 1 )
?

回覆:在列方程中使用數字對象在新列訊息之外定義的任何變數都不應在新列()訊息中使用。
在我的公司,我們有一個自動檢查功能,可以在執行程式碼之前檢測此類程式設計問題。
如果偵測到潛在錯誤,則會向使用者顯示警告訊息並提供一些建議。
回覆:JMP 中的表達式處理:Tipps 和 Trapdoors
For( i = 1, i <= 8, i++,
col = 11 + i;<BR />
l = col - i;
m = col + 1 - i;
colno = Char( col );
Eval(Eval Expr(New Column( "Column " || colno,
Character,
"Nominal",
Formula(
If( Row() == 12,
Lag( Column( 1 ), Expr(l) ),
If( Row() == 13,
Lag( Column( 2 ), Expr(m) ),
Lag( Expr(Name Expr(As Column( col))), 1 )
)
)
)))
);
);
哎喲!因為柱子不懂數字…
回覆:在列方程中使用數字對象For( i = 1, i <= 8, i++,
col = 11 + i;
colname = Column(col) << get name;
l = col - i;
m = col + 1 - i;
colno = Char( col );
Eval(Eval Expr(New Column( "Column " || colno,
Character,
"Nominal",
Formula(
If( Row() == 12,
Lag( Column( 1 ), Expr(l) ),
If( Row() == 13,
Lag( Column( 2 ), Expr(m) ),
Lag( Expr(Name Expr(As Column( colname))), 1 )
)
)
)))
);
);
回覆:在列方程中使用數字對象好球。
回覆:在列方程中使用數字對象@hogi
我從mmarchandFSLR腳本中獲取了一個修改版本(如下所示),運行良好,非常棒的補充。我不確定我是否理解了您的疑問,請解釋一下?
dt = Current Data Table();
Delete Symbols();
dt = Current Data Table();
For( i = 1, i <= 8, i++,
c = 11 + i;
l = 12 - i;
m = 13 - i;
colno = Char( c );
Eval(Eval Expr(New Column( "Column " || colno,
Character,
"Nominal",
Formula(
If( Row() == 12,
Lag( As Column( 1 ), Expr(l) ),
If( Row() == 13,
Lag( As Column( 2 ), Expr(m) ),
Lag( As Column( Expr(c)) , 1)
)
)
)))
);
);
回覆:在列方程中使用數字對象首先,讓我吃驚的是,即使在糾正了周圍的細節之後
Column( col, 1 )
@mmarchandFSLR的解決方案似乎不起作用。
落後()期望的是 As Column() ,而不是柱子() ?!??!
這破壞了我關於使用作為列()存取當前行的值的所有「知識」!
關於作為列 (col)而不是Name Expr(As column(col)):
它確實有效,但它在以下情況下很“脆弱”:
- 新增一列(數字不會更新!)
- 更改了條目(在我的系統上,公式列的條目沒有更新?!?)
[如果重啟後情況好轉,我會刪除此貼文]
回覆:在列方程中使用數字對象似乎值得記錄:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "height 2", Formula( :height ));
New Column( "height 3", Formula( As Column( "height" ) ));
New Column( "height 4", Formula( As Column( 4 ) ));
New Column( "height 5", Formula( Column( 4 )[Empty()] ));
wait(0);
dt[5::10, "height"] = 1;
wait(0);
New window(<< type("modal dialog"), Text Box ("just height 1 got updated ... continue"));
dt << Move Selected Columns( {:height}, after( :name ) );
New window(<< type("modal dialog"), Text Box ("no big difference - now let's recalc"));
dt << rerun formulas();
之前 之後

- 列公式的解譯器理解Column(4)和As Column(4)、Column(“height”)等等....
但是,如果輸入列發生變化,更新列的機制卻不行嗎?必須手動觸發更新嗎?
- 當列移動到另一個位置時,數字不會更新。
我永遠不會在列引用中使用數字!
我永遠不會使用類似列(“高度”)
有趣的事實:
公式編輯器也不喜歡它:

回覆:在列方程中使用數字對象我想我應該描述一下我的黑暗目的。我有一張表格,不知道該做成高表格還是寬表格。第 1 列和第 2 列,第 1-8 行是高表格,第 1-11 列在第 12 行之後變成了寬表格。這個腳本是讓表格更合理的第一步。
之前 之後

我採取了一系列進一步的步驟來處理數據,但這是最棘手的部分。