我们说我有两个data.frames df1
和df2
:
> df1
Var1 Var2
1 "A" "D"
2 "B" "E"
3 "C" "F"
> df2
Var3 Var4
1 "C" "H"
2 "B" "I"
3 "G" "J"
4 "A" "K"
我希望将df1
与df2
合并/合并,使得Var1
和Var3
的值尽可能匹配,否则NA
。Var1
重要的是,我希望保留Var2
和> df2
Var3 Var4 Var1 Var2
1 "C" "H" "C" "F"
2 "B" "I" "B" "E"
3 "G" "J" NA NA
4 "A" "K" "A" "D"
的值之间的映射。在这个简单的例子中,我最终得到:
$sql = $db->query('SELECT c.comment, c.date_comment
FROM comments as c
INNER JOIN joint_a_comments on joint_a_comments.id_comment = c.id
INNER JOIN articles a ON joint_a_comments.id_article = a.id
WHERE a.id ="'.$idarticle.'"
ORDER BY c.date_comment DESC
LIMIT 0,10');
while($result[] = $sql->fetch(PDO::FETCH_ASSOC))
{
$rescomment[] = new Comments($result);
}
return $rescomment;
关于实现这一目标的一般方法的任何想法?每个data.frame中的变量数实际上不一定与本例中的相同。干杯! :)
答案 0 :(得分:0)
使用$entireForm .= $this->addInputError_New_Element($stage_option);
:
match