In example-dataset below, I need to switch the values in column "d_code" with values in column "c_code", if value in column "d_code" begins with anything but "7" and "8".
sample_df <- tibble::tribble(
~sum, ~d_code, ~c_code,
98, "1200", "7300",
73, "1500", "8300",
62, "8400", "1050")
The desired output would look like this:
sum d_code c_code
98 "7300" "1200"
73 "8300" "1500"
62 "8400" "1050"