如何进行循环以将所有行与r中的时间公差匹配?

发布于 2025-02-11 16:31:22 字数 3236 浏览 0 评论 0原文

两个数据库DT1和DT2:

DT1

DATESERVICE_IDROUTE_IDID_ID ID_COURSEstop_nameDewtrure_time
2021-04-06-931MONET05:14:00
1899-12-311-31TCAR_R我有Théâtredes Arts08:44:00
2021-04-09TCAR_R-33HAMEAUdefrévaux1899-12-3112:45:00
2021-04-04-04-041-31251899-12-31HôtelDeVille16:21:00
2021-04-061-31120348de08:05:00

1899-12-31

-l'RUE1899-12-31TCAR_REglise
​-06TCAR_R-1-31934960莫奈1899-12-31 05:14:00
2021-04-08TCAR_R-1-31212103THéâtreArtsArtsArts Arts Arts1899-12-31
08:39:00TCAR_R-1-31131211HôteldeVille1899-12-31 16:19:00
TCAR_R_R-1-31252334HAMEAUdeFRévaux18999999999-12-31 12:47:00
2021-04-09TCAR_R-1-3112014542RUE de l'Eglise1899-12-31 07:59:00

我想将DT1的线与DT2的线与以下公差匹配:

**确切的公差日期,stop_name,service_id and service_id and and service_id and and service_id and and service_id and and service_id and and service_id and and service_id and and和route_id

** Random tolerance on Departure_time: ie tolerance interval must change "n" times until all rows in DT1 match in DT2

the desired output is:

Dateservice_idroute_idid_coursestop_nameDeparture_timeDT1trip_idDeparture_timeDT2
2021-04-06TCAR_R-1-31931莫奈1899-12-31 05:14:0049601899-12-31 05:14:00
2021-04-07TCAR_R-1-3121512ARTS ARTS ARTS189999-12-31 08:44:00THETEARTS 12-31 08:39:00
2021-04-09-1-312533HAMEAUdefrévaux1899-12-31 12:45:00233412:47:00
1899-12-31TCAR_R -1-31132HôtelDeVille1899-12-3116:21:0012111899-12-31 16:19:00
2021-04-06TCAR_R-1-31120348RUE DE L'EGLISE1899-12 -31 08:05:00145421899-12-31 07:59:00

我想在R中使用一个循环进行此操作,因为我的两个数据库很大,我真的很感谢任何帮助!

I have two databases DT1 and DT2:

DT1

Dateservice_idroute_idid_coursestop_nameDeparture_time
2021-04-06TCAR_R-1-31931Monet1899-12-31 05:14:00
2021-04-08TCAR_R-1-3121512Théâtre des Arts1899-12-31 08:44:00
2021-04-09TCAR_R-1-312533Hameau de Frévaux1899-12-31 12:45:00
2021-04-09TCAR_R-1-31132Hôtel de Ville1899-12-31 16:21:00
2021-04-06TCAR_R-1-31120348Rue de l'Eglise1899-12-31 08:05:00

DT2

Dateservice_idroute_idtrip_idstop_nameDeparture_time
2021-04-06TCAR_R-1-31934960Monet1899-12-31 05:14:00
2021-04-08TCAR_R-1-312121203Théâtre des Arts1899-12-31 08:39:00
2021-04-09TCAR_R-1-31131211Hôtel de Ville1899-12-31 16:19:00
2021-04-09TCAR_R-1-31252334Hameau de Frévaux1899-12-31 12:47:00
2021-04-06TCAR_R-1-3112014542Rue de l'Eglise1899-12-31 07:59:00

I want to match the lines of DT1 with those of DT2 with the following tolerances:

** Exact tolerance on Date, stop_name, service_id and route_id

** Random tolerance on Departure_time: i.e. tolerance interval must change "n" times until all rows in DT1 match in DT2

the desired output is:

Dateservice_idroute_idid_coursestop_nameDeparture_timeDT1trip_idDeparture_timeDT2
2021-04-06TCAR_R-1-31931Monet1899-12-31 05:14:0049601899-12-31 05:14:00
2021-04-07TCAR_R-1-3121512Théâtre des Arts1899-12-31 08:44:00212031899-12-31 08:39:00
2021-04-09TCAR_R-1-312533Hameau de Frévaux1899-12-31 12:45:0023341899-12-31 12:47:00
2021-04-09TCAR_R-1-31132Hôtel de Ville1899-12-31 16:21:0012111899-12-31 16:19:00
2021-04-06TCAR_R-1-31120348Rue de l'Eglise1899-12-31 08:05:00145421899-12-31 07:59:00

I want to do this with a loop in R because my two databases are very large, I will be really grateful for any help!

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

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

发布评论

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