删除/移动其他数据框中具有匹配值的行
我目前正在努力在某些系统错误发生后管理产品退款。 我有一个巨大的XLXS列表(表1),所有等待的退款几周。但是,该表中的某些记录已手动退还并存储在单独的文件中(表2)。
以下是我的数据集的示例:
所有退款表:
数字 | 订购 | 数量 | 状态 |
---|---|---|---|
1 | 123456789 | 150.50 | 待定 |
2 | 235641458 | 250.30 | 待定 |
3 | 235984258 | 50.20 50.20 50.20 | 迫在眉睫 |
4 | 283478566 | 102.45 | 悬而未决 |
数字 | 订单 | 数量 | 状态 |
---|---|---|---|
1 1 | 123456789 | 150.50 | 退还 |
2 | 235641458 | 250.30 250.30 | 退还 |
我现在希望做的是删除(最好移动到单独的表中)“所有退款表”中的行与“订单订单”匹配的“订单”的“手动退还表”的订单Number匹配。你们能帮我吗?
谢谢!
I'm currently working on managing refunding of products after some systems errors occured.
I have a huge xlxs list (table 1) with all pending refunds of a couple of weeks. However, some of the records in that table have been manually refunded and stored in a seperate file (table 2).
Here is an example of my data sets:
All refunds table:
number | ordernumber | Amount | Status |
---|---|---|---|
1 | 123456789 | 150.50 | pending |
2 | 235641458 | 250.30 | pending |
3 | 235984258 | 50.20 | pending |
4 | 283478566 | 102.45 | pending |
Manually refunded table
number | ordernumber | Amount | Status |
---|---|---|---|
1 | 123456789 | 150.50 | refunded |
2 | 235641458 | 250.30 | refunded |
What I now wish to do is delete (preferably move to a separate table) the rows in the 'all refunds table' whenever the ordernumber matches the ordernumber in the 'manually refunded table'. Could you guys help me out?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
base
r,您可以将匹配的OrderNumber与以下代码进行子集匹配:然后您可以制作一个带有匹配行的新表,然后从All_refunds表中删除行,例如:
给出输出:
With
base
R you can subset matching ordernumber's with following code:You can then make a new table with matching rows and remove the rows from all_refunds table, like this:
Giving the output:
您可以尝试
You may try
这也称为“过滤加入”,请参见 https://dplyr.tidyverse.org.org.org.org.org.org.org /reference/filter-joins.html
This is also known as "filtering joins", see https://dplyr.tidyverse.org/reference/filter-joins.html