這已報告給 JMP 支持人員,他們已將其作為錯誤提交給開發 (00049239)。 似乎至少在 JMP16.2 和 JMP17.0 中會發生
需要注意的是,在使用上述組合(設置每個值、循環和列統計函數)時,JMP 存在相當嚴重的錯誤。 所發生的情況是,在將數據添加到不同的表時,JMP 確實使用了錯誤表中的數據。 一種解決方法是在 << Set Each Value (<< Set Each Value(Col Rank(Row(), dt:name))) 中提供表首選項。
你似乎需要(根據我相當快的測試):
- 具有相同列名的數據表
- 循環那些
- 使用 << Set Each Value 設置列中的值
- 使用的公式應使用Col統計函數和byVar(很可能這在兩個表中必須具有相同的名稱)
下面是一些測試用例
Names Default To Here(1);
// https://www.jmp.com/support/help/en/17.0/#page/jmp/scoping-operators.shtml#
// Initialize data
test_tables = {};
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
dt = Open("$SAMPLE_DATA/Students1.jmp");
dt << Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
/*
dt = Open("$SAMPLE_DATA/Students2.jmp");
dt << Sort(By(:name), Replace Table, Order(Ascending)); // sort to create worse scenario
dt << New Column("REAL NAME RANK", Numeric, Continuous, Formula(Col Rank(Row(), :NAME)));
Column(dt, "age") << Set Modeling Type("Continuous");
Insert Into(test_tables, dt);
*/
// use idx 1 to skip first table
min_idx = 0;
// without reversing we will run out of index as we are using wrong table
// but if we reverse we will get worse outcome (in my opinion) as we end up with wrong data
reverse_tableorder = 0;
If(reverse_tableorder,
test_tables = Reverse(test_tables);
);
For Each({dt, idx}, test_tables,
// works
// dt << New Column("COPY", Character, Nominal, << Set Each Value(:NAME));
// dt << New Column("MULTI", Numeric, Continuous, << Set Each Value(:age * :age));
If(idx > 0, // if the column isn't created to first table seems to work fine?
// Doesn't work (// old table used due to some col function optimizations when using byVar?)
Try(
dt << New Column("RANK", Numeric, Continuous, << Set Each Value(Col Rank(Row(), :NAME)));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("RANK_SEPARATE", Numeric, Continuous);
new_col << Set Each Value(Col Rank(:Row(), :name));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("SUM", Numeric, Continuous, << Set Each Value(Col Sum(1)));
,
show(exception_msg);
);
Try(
new_col = dt << New Column("SUM_WITH_GROUP", Numeric, Continuous, << Set Each Value(Col Sum(1, :name)));
,
show(exception_msg);
);
Try( // with reverse_tableorder = 1, :age is taken from correct table BUT the group sizes from wrong?
// KATIE -> 72 (6*12) and not 11+12+12+13+14+15 -> 77
new_col = dt << New Column("SUM_OF_COL", Numeric, Continuous);
new_col << Set Each Value(Col Sum(:age, :name));
,
show(exception_msg);
);
// workaround
dt << New Column("RANK_WITH_REF", Numeric, Continuous, << Set Each Value(
Col Rank(Row(), dt:NAME)
));
);
);從 JMP 支持中獲得了一些好的信息,但不太好的信息。
好的:
這是 Col Rank 函數的一個錯誤(不確定是否測試了其他 Col 函數),並將在某個時候修復(JMP17.2 不會修復)。
絕對不是那麼好:
<< 設置每個值不應用於為列設置值,除非它是常量或“全局函數”(today()),並且 Col 統計函數中的第一個參數應始終是列引用。 當前的行為不被視為錯誤,而是意外行為,因此它們可能會在沒有任何信息的情況下更改任何點。 我將創建願望清單項目,以便他們將這些變成受支持的行為,而不是意外的行為。
編輯:使在 Set Each Value 中使用公式表達式以及在 Col 統計公式中使用表達式作為第一個參數支持的行為
Col 統計數據嚴格要求使用列作為第一個參數 - 禁止使用表達式?
這將是一個巨大的倒退!
許多美麗的技巧@brady_brady不再工作了:(
使用 JMP18:很棒,似乎已修復:

但 Col Sums 似乎仍然有問題...

這個問題可以透過明確引用 dataTable:column 來解決,類似於第一篇文章中 Jarmo 的範例:
new_col = dt << New Column("SUM_WITH_GROUP", Numeric, Continuous, << Set Each Value(Col Sum(1, dt:name))); // dt:name instead of name
new_col << Set Each Value(Col Sum(dt:age, dt:name)); // dt:age(name) instead of :age(name)