R 中的内部联接返回更大的数据帧?

发布于 2025-01-18 07:31:16 字数 702 浏览 3 评论 0原文

我正在尝试内部联接两个表(仅保留两个表中“联接依据”变量所在的行),但生成的表比原始表大,我不确定为什么。

例如,我尝试合并 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")

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文