需要有關列公式的協助你好,
我想將此循環轉換為等效的列公式
Names Default To Here( 1 );
dt = Current Data Table();
// Assuming Column B is column 2
testColumn = Column( dt, 1 );
llCol = dt << New Column( "LL Limit_7.5", Numeric );
ulCol = dt << New Column( "UL Limit_7.5", Numeric );
// Loop through each row starting from row 20
For( i = 20, i <= N Rows( dt ), i++,
data = testColumn[1 :: i]; // Get values from row 20 to the current row
q1 = Quantile( 0.25, data ); // 1st Quartile
q3 = Quantile( 0.75, data ); // 3rd Quartile
// Factor value is 6
factorValue = 7.5;
// Calculate ll and ul
llx = q1 - (q3 - q1) * (factorValue - 0.675) / 1.35;
ulx = q3 + (q3 - q1) * (factorValue - 0.675) / 1.35;
// Set the calculated values in the new columns
llCol[i] = llx;
ulCol[i] = ulx;
);
我嘗試過,但似乎不正確。有什麼建議嗎?
newColExpr = Expr(
llCol << Set Formula(
If( Row() >= 20,
Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) ) - (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
);
ulCol << Set Formula(
If( Row() >= 20,
Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) ) + (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
);
);
Eval( Eval Expr( newColExpr ) );
自動化和腳本編寫回覆:需要有關列公式的協助你能解釋一下你想做什麼嗎?
回覆:需要有關列公式的協助計算 PAT 限制
回覆:需要有關列公式的協助你可以做這樣的事情,但我不確定這是否是最好的方法
Names Default To Here(1);
dt = Open("$DOWNLOADS/data_table.jmp");
dt << New Column("Low", Numeric, Continuous, Formula(
As Constant(
factorValue = 7.5;
);
If(Row() < 20,
.
,
m = :Data[1::Row()];
q1 = Quantile(0.25, m);
q3 = Quantile(0.75, m);
q1 - (q3 - q1) * (factorValue - 0.675) / 1.35;
);
));
dt << New Column("High", Numeric, Continuous, Formula(
As Constant(
factorValue = 7.5;
);
If(Row() < 20,
.
,
m = :Data[1::Row()];
q1 = Quantile(0.25, m);
q3 = Quantile(0.75, m);
q3 + (q3 - q1) * (factorValue - 0.675) / 1.35;
);
));
回覆:需要有關列公式的協助
有趣的是,對於 Col Quantiles 來說,首先是列,然後是分位數。
除此之外, Col Quantile將獲取所有行 - 而不是行1::currentRow
-> 將產生一個常數值。

newColExpr = Expr(
new column("llCol" ,Formula(
If( Row() >= 20,
Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) ) - (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
));
new column("ulCol" , Formula(
If( Row() >= 20,
Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) ) + (Col Quantile( 0.75, Expr( TestColumn( 1, Row() ) ) )
-Col Quantile( 0.25, Expr( TestColumn( 1, Row() ) ) )) * (Expr( factorValue ) - 0.675) / 1.35,
.
)
));
);
Eval(Eval Expr( newColExpr )) ;