R 中的内部联接返回更大的数据帧?
我正在尝试内部联接两个表(仅保留两个表中“联接依据”变量所在的行),但生成的表比原始表大,我不确定为什么。
例如,我尝试合并 enroll_dsnp
和服务以获得 serv_enroll
。目标是使用此联接消除 enroll_dnsp 中未在服务中表示的行。但是,生成的 serv_enroll
文件 (15k) 比 enroll_dsnp
文件 (14k) 大。这是为什么?我该如何解决我的问题?
我尝试了以下解决方案:
serv_enroll <- merge(x = enroll_dsnp, y = service, by = "Contract_State_County",
all = FLASE, all.x = FALSE, all.y = FALSE, no.dups = TRUE)
serv_enroll <- enroll_dsnp %>% inner_join(service, by = "Contract_State_County")
I'm attempting to inner join two tables (keep only rows where the "join by" variable is in both tables) but my resulting table is bigger than my original table and I'm not sure why.
For example, I am trying to merge enroll_dsnp
and service to get serv_enroll
. The goal is to use this join to eliminate rows in enroll_dnsp that are not represented in service. However, the resulting serv_enroll
files is larger (15k) than the enroll_dsnp
file (14k). Why is this and how can I fix my issue?
I've tried the following solutions:
serv_enroll <- merge(x = enroll_dsnp, y = service, by = "Contract_State_County",
all = FLASE, all.x = FALSE, all.y = FALSE, no.dups = TRUE)
serv_enroll <- enroll_dsnp %>% inner_join(service, by = "Contract_State_County")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论