这已报告给 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)