使用 Update() 將新行添加到主表中我正在嘗試更新有時包含新行(基於索引)的表。
看來我需要使用 join,因為以下似乎不起作用(這裡,索引是名稱列)。
Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = New Table( "Little Class",
Add Rows( 3 ),
New Column( "name",
Character,
Nominal,
Set Values( {"ALICE", "NEW_NAME", "OTHER_NEW_NAME"} )
),
New Column( "height",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "weight",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "RANK",
Continuous,
Set Values( [3, 1, 2] )
),
New Column( "CODE",
Continuous,
Set Values( [0, 1, 1] )
)
);
dt1 << Update(
With( Data Table( "Little Class" ) ),
Match Columns( :name = :name ),
Add columns from Update table( {:RANK} )
);
數據混合和清理回复:使用 Update() 將新行添加到主表中新的加入平台可能如下所示:
https://community.jmp.com/t5/JMP-Wish-List/Tables-join-option-to-update-main-table/idc-p/653857/highlight/true#M4537

回复:使用 Update() 將新行添加到主表中我寫了一個希望添加一個更新主表的選項:
表連接:更新主表的選項
請隨意支持它:)
回复:使用 Update() 將新行添加到主表中大多數時候我會使用不可見表來完成此操作,因為這樣可以從 JMP 窗口列表中輕鬆打開它們(如果它們尚未關閉)。
不可見的表格在窗口列表中呈灰色(透明),您可以通過雙擊它們使它們可見。

我還建議向表添加名稱,因為當打開大量表並且由於某種原因代碼無法正確執行時,可以更輕鬆地開始調試。 如果不重命名,它們就會變得一團糟,例如:某物 1 的子集、某物 2 的子集、無標題 1 等等。
下面是一個示例,它將打開 dt 作為不可見表並創建 dt_new 作為不可見表。 然後將它們加入到名為 JOINED_TABLE 的新表中,該表將顯示給用戶,最後關閉 dt 和 dt_new 而不保存它們。 <BR />
</CODE><CODE class=" language-jsl">Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", invisible);
dt_new = New Table( "Little Class",
Add Rows( 3 ),
New Column( "name",
Character,
Nominal,
Set Values( {"ALICE", "NEW_NAME", "OTHER_NEW_NAME"} )
),
New Column( "height",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "weight",
Continuous,
Set Values( [999, 999, 999] )
),
New Column( "RANK",
Continuous,
Set Values( [3, 1, 2] )
),
New Column( "CODE",
Continuous,
Set Values( [0, 1, 1] )
),
invisible
);
dt_joined = dt << Join(
With(dt_new),
Merge Same Name Columns,
By Matching Columns(:name = :name),
Drop multiples(0, 0),
Include Nonmatches(1, 1),
Preserve main table order(1),
Output table("JOINED_TABLE")
);
Close(dt, no save);
Close(dt_new, no save);
回复:使用 Update() 將新行添加到主表中我懂了。 為了讓最後一步變得簡單,您有什麼建議?
我有“dt”(原始)和“dt_joined”(“dt”+“dt_new”)。
回复:使用 Update() 將新行添加到主表中我測試了相同的選項,它的行為方式相同,它確實創建了新表。
我可以分擔在 JMP 中處理打開表的痛苦,但是在編寫腳本時相當容易(將添加一些額外的代碼),打開/創建它們作為不可見/私有,並在知道不會保存後立即關閉它們而不保存不再需要它們了。
回复:使用 Update() 將新行添加到主表中“除非你必須處理額外的桌子”
確切地。 儘管我正在使用選定的更新選項進行聯接,但仍會生成一個新表。
dt<< Join(
With( dt_new ),
Update, // this option is selected
By Matching Columns( :index= :index),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )<BR />);<BR /><BR />// Opens new table apart of dt and dt_new回复:使用 Update() 將新行添加到主表中在社區中找到類似的帖子,建議在添加新行時使用 Join 而不是 update :
更新 JMP 數據表
有沒有理由不能使用聯接而不是更新(除非您必須處理額外的表)?
來自 JMP 幫助:更新數據表:
如果您有兩個數據表並且想要使用新表中的數據更新原始表,請選擇表格 > 更新。 Update 命令是就地加入的一個特例。 這是選中“更新”選項的“加入” ,並且它不會產生新表。
回复:使用 Update() 將新行添加到主表中您所說的假設是正確的,您將必須使用 Join 平台來做您想做的事。