如何按另一列縮放列您好,我有一個表格,結構如下:一些名目列和很多數值列。

我想建立一個新的「table_scaled」表,其中包含名義列,並將 N(#) 列除以「N rows」列,再乘以 100,得到百分比。我嘗試了以下程式碼,但只得到了一個空的新表,其中有一列為空白。請問有什麼建議嗎?
dt = Current Data Table();
NewTable("HOT_COLD_summary_scaled",
For( i = 1, i <= N Cols( HOT_COLD_summary ), i++,
dt << New Column(
Column( i ) << get name,
Numeric,
"Continuous",
Formula( (:column( i )*100) /(HOT_COLD_summary:N rows) )
)
)
);
自動化和腳本編寫資料存取大規模客製化品質與工藝工程回复:如何按另一列縮放列您能否提供一個帶有正確值的示例,說明您希望最終表格的外觀如何? 還可以提供可用於開發腳本的數據表(刪除源腳本並在需要時匿名),因為表的圖片不能用於此。
回复:如何按另一列縮放列嗨,亞爾莫,
謝謝,肯定的事情。 我附上了作為起始表的摘要,而 summary_scaled 是我想要編寫的腳本。
回复:如何按另一列縮放列如果您有 JMP16+,這裡是一個選項
Names Default To Here(1);
dt = Open("$DOWNLOADS/summary.jmp");
dt_copy = dt << Subset(All Rows, Selected Columns(0), Output table("summary_scaled"));
close(dt, no save);
col_list = dt_copy << Get Column Names("String");
// first col isn't needed, second col is expected to be N Rows -> skip those
cols_of_interest = Remove(col_list, 1,2);
For Each({ncol}, cols_of_interest,
new_col = Eval(EvalExpr(
dt_copy << New Column(ncol ||"_scaled%", Numeric, Continuous, Formula(
100*Expr(Name Expr(AsColumn(ncol))) / :"N Rows"n
))
));
dt_copy << Move Selected Columns({new_col}, after(Eval(ncol)))
);
如果您有較舊的 JMP,則必須將 For Each 替換為 For 循環。