使用 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 的列你能提供一個樣本數據表嗎?