Remove duplicated 2 columns permutations

前端 未结 2 1770
长发绾君心
长发绾君心 2020-12-19 11:22

I can\'t find a good title for this question so feel free to edit it please.

I have this data.frame

  section time to from
1       a    9  1    2
2           


        
2条回答
  •  长情又很酷
    2020-12-19 11:45

    You can try using sort within the apply function to order the combinations.

    mydf[!duplicated(t(apply(mydf[3:4], 1, sort))), ]
    #   section time to from
    # 1       a    9  1    2
    # 3       a   12  2    3
    # 4       a   12  2    4
    # 6       a   12  3    4
    

提交回复
热议问题