0

Suppose there are two datasets with same columns: A B C. I merged two datasets by A. However, the merged dataset has columns called B.x, B.y, C.x, C.y. But I only want to have B and C in new dataset. How to solve this question?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Yimin
  • 1
  • Does this answer your question? [How to join (merge) data frames (inner, outer, left, right)](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right) – Russ Thomas Sep 15 '20 at 21:23

1 Answers1

0

You can remove the .x and drop the .y with this script:

joined_df <- joined_df %>% 
    rename_at(vars(ends_with(".x")),
    ~str_replace(., "\\..$","")) %>% 
    select_at(vars(-ends_with(".y")))