Drawing on the discussion on conditional dplyr evaluation I would like conditionally execute a step in pipeline depending on whether the reference column exists in the passed da
This code does the trick and is pretty flexible. The ^ and $ are regex used to perform an exact match.
mtcars %>% set_names(names(.) %>% str_replace("am","1") %>% str_replace("^cyl$","2") %>% str_replace("Doesn't Exist","3") )