79286519

Date: 2024-12-17 02:18:46
Score: 1.5
Natty:
Report link

If you are a user of the tidyverse packages, particularly dplyr you could do the following...

library(dplyr)

#Create a named vector of old names, and new names.
name_vector <- A %>% pull(col1)
names(name_vector) <- A %>% pull(col2)


rename(B, all_of(name_vector))

The tidy selection all_of() forces strictness when renaming. But depending on your exact use case and rigidity you could modify this.

Cheers

Reasons:
  • Blacklisted phrase (1): Cheers
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: MjStansfi