我正在嘗試更新有時包含新行(基於索引)的表。
似乎我需要使用連接,因為以下似乎不起作用(這裡,索引是名稱列)。
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} )
);
您陳述的假設是正確的,您將不得不使用 Join 平台來做您想做的事。
在這裡找到了來自社區的類似帖子,建議在添加新行時使用 Join 而不是 update:
更新 JMP 數據表
是否有理由不能使用 join 而不是 update (除非您必須處理額外的表)?
來自 JMP 幫助:更新數據表:
如果您有兩個數據表並想用新表中的數據更新原始表,請選擇表格 > 更新. 更新命令是就地聯接的特例。 這是一個選中更新選項的連接,並且不會生成新表。
“除非你必須處理額外的桌子”
確切地。 儘管我在選擇更新選項的情況下進行連接,但還是生成了一個新表。
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