如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列我想得到以下結果:比較dt1與dt2,如果存在“ Id”不匹配,則用dt1所有行創建一個新表dt3,並將dt2中不匹配的行添加到dt1中,然後選擇3列(名稱,批次,EPval)在dt3中顯示。非常感謝
dt1 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"11889922", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Name", character, values( {"John", "Joe", "PP"} ) )
);
dt2 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"33888822", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Mgr", character, values( {"J", "H", "P"} ) )
);數據表回复:如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列感謝您的回复。但是,您運行腳本嗎?它在我的電腦上不起作用。我正在使用JMP14,不確定是否是因為這個。dt3沒有彈出
回复:如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列顯然,我無意中刪除了合併的“ With”元素。 不知道我是怎麼做到的.....但是....這裡是正確的代碼
/*I Want to get the result of: compare dt1 with dt2, if there are "Id" don't match then create a new table dt3 with dt1 all rows, and add the don't match rows in dt2 into dt1, and pick 3 columns(name, lot, EPval) show out in dt3. thanks a lot */
dt1 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"11889922", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Name", character, values( {"John", "Joe", "PP"} ) )
);
dt2 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"33888822", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Mgr", character, values( {"J", "H", "P"} ) )
);
// I assumed that there
dt3 = dt1 << Join( with(dt2),
By Matching Columns( :Id = :Id ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )
);
回复:如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列
這是日誌仍然無法正常工作。我可能會再舉一個例子來問這個問題。如果第二個示例正常工作,那麼我們可以忽略此示例。
//:* /
dt3 = dt1 << Join(
通過匹配列(:Id =:Id),
刪除倍數(0,0),
包括不匹配項(1,1),
保留主表順序(1)
);
/ *:
加入未知的數據表{3}
回复:如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列您需要做的就是使用
表格==>加入
並為“主要”表和“與”表指定為“包括不匹配項”
/*I Want to get the result of: compare dt1 with dt2, if there are "Id" don't match then create a new table dt3 with dt1 all rows, and add the don't match rows in dt2 into dt1, and pick 3 columns(name, lot, EPval) show out in dt3. thanks a lot */
dt1 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"11889922", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Name", character, values( {"John", "Joe", "PP"} ) )
);
dt2 = New Table( "test",
addrows( 3 ),
New Column( "lot", character, values( {"K1", "K2", "K3"} ) ),
New Column( "Id", numeric, values( {"33888822", "11776620", "22889955"} ) ),
New Column( "EPval", numeric, values( {1, 2, .} ) ),
New Column( "Mgr", character, values( {"J", "H", "P"} ) )
);
// I assumed that there
dt3 = dt1 << Join( with(dt2),
By Matching Columns( :Id = :Id ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )
);回复:如何用dt1的所有行創建dt3,再加上與dt1的“ Id”列不匹配的dt2行,結果僅顯示dt1和dt2中的幾列您顯示的代碼不是我發布的正確代碼。 正確的JOIN代碼是
dt3 = dt1 << Join( with(dt2),
By Matching Columns( :Id = :Id ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 1 ),
Preserve main table order( 1 )
);