Hi , I try to replace some values from one data frame (lets call it: "xrt") by compare to another data frame (lets call it:"code names") and if they match, replace old value in "xrt " to new values from "code names" in another column.
So let's I show:
That output of my first df - xrt.
I have column with 1777 row with codes (total levels is 68)
A tibble: 1,777 x 2
XRT_code_small Date_XRT
1 77261 2015-07-30
2 77261 2015-08-02
3 77295 2015-07-23
4 77401 2015-08-03
5 77401 2015-08-05
6 77401 2015-08-06
7 77401 2015-08-09
8 77401 2015-08-10
9 77401 2015-08-11
10 77401 2015-08-12
... with 1,767 more rows
Another df - code names:
A tibble: 68 x 2
Input_Code Name_code
1 77261 General_Office
2 77280 General_Office
3 77295 General_Office
4 77401 General_Office
5 81781 General_Office
6 77751 NA
7 77753 NA
8 77900 WBRT 3D
9 77902 NA
10 77903 Brain 3D
...with 58 more rows
So I want compare columnt XRT_code from "xrt" to Input_Code from "code names" and if it match - replase with name from column Namec_code respectively.
I trying case_when function, but unsuccessfully.
Join_left good soltion (Thanks for user mishabalyasin) but again is at really write any function with statement IF?
Thank you