说我有这两个数据集,每个都有一个列,分别是FirstName和Name。 我想应用左联接并查看结果,以使结果表显示为FirstName(从左表),Name(从右表),而在FirstName = Name上左联接。
我遇到的问题是,left_join的最终结果是一个单独的列,即FirstName,而我也想查看在其上被联接的列。知道如何实现吗?
t1 <- data.frame(FirstName= c('a','b','c','d'))
t2 <- data.frame(Name= c('a','b','c'))
library(dplyr)
t1%>%
left_join(t2, c('FirstName' = 'Name'))
如您所见,上面的结果是一个单独的列,而名字是Firstname。它会自动从另一个表中忽略“名称”列,这就是我不希望这样做的原因。
答案 0 :(得分:0)
您可以在加入之前创建名称列的副本
g++ -I. -MMD -I/usr/share/verilator/include -I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -faligned-new -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow -c -o module.o ../module.cpp
g++ -I. -MMD -I/usr/share/verilator/include -I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -faligned-new -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow -c -o verilated.o /usr/share/verilator/include/verilated.cpp
g++ -I. -MMD -I/usr/share/verilator/include -I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -faligned-new -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow -c -o verilated_vcd_c.o /usr/share/verilator/include/verilated_vcd_c.cpp
g++ -I. -MMD -I/usr/share/verilator/include -I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -faligned-new -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow -c -o Vmodule__ALLcls.o Vmodule__ALLcls.cpp
g++ -I. -MMD -I/usr/share/verilator/include -I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=1 -faligned-new -Wno-sign-compare -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable -Wno-shadow -c -o Vmodule__ALLsup.o Vmodule__ALLsup.cpp
ar r Vmodule__ALL.a Vmodule__ALLcls.o Vmodule__ALLsup.o
ranlib Vmodule__ALL.a
g++ module.o verilated.o verilated_vcd_c.o Vmodule__ALL.a -o Vmodule