使用 refs 删除列你好
我写了一个脚本来删除一列。但是,我收到错误消息“当公式将此列引用到另一列时无法删除此列。 “
没有公式,但如果手动使用“删除引用”选项,我可以手动删除列。
我需要学习如何在我的脚本中使用这个函数来使用“Remove Refs”
我正在使用 JMP 16.1.0
高级统计建模自动化和脚本消费者和市场研究数据混合和清理回复:删除带有 refs 的列我向 JMP 支持部门报告的问题现已作为错误披露并已报告给研发部门。
因为可以交互地删除公式,所以我想到您可以使用 << Delete property("Formula") 而不是 << Delete Formula 并且它似乎有效,但在创建汇总表时我会非常小心地使用公式因为他们可能会有一些非常奇怪的互动
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
//create some formula colums
dt << New Column("deduction", Numeric, "Continuous", Format("Best", 12), Formula(:height - :weight));
dt << New Column("concat_col", Character, "Nominal", Formula(:name||"_"||Char(:name)));
dt_summary = dt << Summary(
Group(:name,:sex, :concat_col),
Mean(:height),
Mean(:deduction),
Freq("None"),
Weight("None"),
Link to original datatable(0)
);
Try(
f1 = Column(dt_summary, "concat_col") << Get Formula;
show(f1);
Column(dt_summary, "concat_col") << Delete Formula;
f2 = Column(dt_summary, "concat_col") << Get Formula;
show(f2);
,
show(exception_msg);
);
Try(
f3 = Column(dt_summary, "concat_col") << Get Formula;
show(f3);
Column(dt_summary, "concat_col") << Delete Property("Formula");
f4 = Column(dt_summary, "concat_col") << Get Formula;
show(f4);
dt_summary << Delete Column("name");
,
show(exception_msg);
);
/*
Close(dt_summary, no save);
Close(dt, no save);
*/回复:删除带有 refs 的列问题与汇总表有关吗?
就在今天,当我试图删除公式时,我确实注意到汇总表有一些奇怪的行为。 我目前正在测试这个问题,并会在我提供适当的示例后向 JMP 支持部门发送票证。 准备好后,我也可以在这里发布示例。
编辑:
这是关于我今天遇到的问题的简单示例(我很少使用公式......):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
//create some formula colums
dt << New Column("deduction", Numeric, "Continuous", Format("Best", 12), Formula(:height - :weight));
dt << New Column("concat_col", Character, "Nominal", Formula(:name||"_"||Char(:name)));
dt_summary = dt << Summary(
Group(:name,:sex, :concat_col),
Mean(:height),
Mean(:deduction),
Freq("None"),
Weight("None"),
Link to original datatable(0)
);
Try(
dt_summary << Delete Column("name");
,
show(exception_msg);
);
Try(
f = Column(dt_summary, "concat_col") << Get Formula;
show(f);
Column(dt_summary, "concat_col") << Delete Formula;
,
show(exception_msg);
);
/*
Cannot delete column "name" while it is referenced by the formula of column "concat_col".
Removing a formula leaves the data unchanged. Removing references replaces each reference with an empty value. These effects are permanent and cannot be undone.
f = :name || "_" || Char(:name);
exception_msg = {"Column concat_col has no formula"(1, 2, "Delete Formula", Delete Formula /*###*/)};
*/
左侧列列表中的公式不可见,公式面板框中的公式也不可见。

如果我单击“编辑公式”,公式就在那里。 如果我将连接中的“_”更改为“”,则公式消失,列被锁定并且数据表中的值确实发生了变化:


在这种情况下,简单的修复可能是在创建汇总表之前先从原始数据表中删除所有公式,但我认为不应将公式(仅值)复制到汇总表,因为它可能有一些非常奇怪的行为取决于公式。
编辑2:
我现在已经向 JMP 支持部门发送了关于我描述的这个问题/功能的票证。
回复:删除带有 refs 的列不知是否有隐藏的公式栏? 如果真的没有公式列,这听起来像是一个错误,将表格发送给技术支持可以帮助修复它。
回复:删除带有 refs 的列您可能想退后一步,考虑一下您正在使用的方法。 与其解决这个问题,不如从一开始就避免它。 例如,为什么要在其他数据列中使用公式? 为什么要删除列?
您可能能够使用其他方法来填充根本不涉及公式的数据列。 编写 JMP 脚本时使用公式的唯一原因是您需要在数据表更改时更新数据列。 否则还有其他方法。
你能发布你的脚本吗? 或者描述您的脚本执行的步骤?
回复:删除带有 refs 的列你能提供一个样本数据表吗?