如何用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 )
);