我有第一个表“结果”,大小为5313行,第二个表“Lpp_sans_rss”,大小为3889行。我想通过在第一个表的最后一列中的第二个表中仅添加第二列“lpp_libelle”来创建表之间的合并。我的问题是:当我在这两个表之间进行合并时,我得到“124556”行。我希望通过添加每个“lpp_code”的“libell”来保持第一个表的大小相同
表1的例子:
/**
* Invoke a remote procedure over WS on the specified session, with the given arguments.
* @param session The target session on which to send the RPC message
* @param target The name of the procedure to call
* @param arguments The arguments to be sent in the message
* @return
*/
public CompletableFuture<Map<String,Object>> invoke(WebSocketSession session, String target, Map<String, Object> arguments){
Invocation invocationMessage = new Invocation(target, arguments);
invocationMessage.setId(getNextId());
// completeable future for the result. It does nothing, will be completed when reply is received which happen in a different thread, see completeInvocation
CompletableFuture<Map<String, Object>> invocationFuture = new CompletableFuture<>();
CompletableFuture<Void> senderFuture = sender.sendMessage(session, invocationMessage);
// handle problem in the sending of the message
senderFuture.exceptionally(e -> {
// is this correct ??
invocationFuture.completeExceptionally(e);
return null;
});
// store the pending invocation in the registry
registry.addPendingInvocation(new PendingInvocation(invocationMessage, session, invocationFuture));
// return the future so the caller can have access to the result once it is ready
return invocationFuture;
}
表2的例子:
code_acte;lpp_code;count;expected_count;p-value;ROR;drug_margin;event_margin;FDR
NGQK001 ;985675;3;0.00894810101411811;9.99200722162641e-16;689.196078431372;105;6;2.11945533050936e-16
DASA006 ;985536;3;0.0159787518109252;9.99200722162641e-16;288.012295081967;9;125;2.11778383576921e-16
答案 0 :(得分:1)
首先,查找table1中的每个lppcode
查看table2中lpp_libelle对于该lppcode的内容
将该值放在table1的第10列的table1中
for (i in length(table1[,2])){
table1[i,10]=as.character(table2[which(table2[,1]==table1[i,2]),2])
}
编辑:Ferdi的回答更优雅。
答案 1 :(得分:1)
以下问题中描述的左外连接(或简称左连接)应该可以解决您的问题。
merge(x = results, y = Lpp_sans_rss, by = "ENTERHEREYOURCRITERIA", all.x = TRUE)
How to join (merge) data frames (inner, outer, left, right)?