Is there a clever way to use the rename function in dplyr when in some instances the column to be renamed doesn't exist?
For example, I would like the following not to result in an error
mtcars%>%rename(miles_per_gallon=mpg,missing_varible=foo)
(results in this: Error: Unknown variables: foo.)
but rather the dataframe with all possible renaming done.
Currently I am explicitly checking that the specific column exists before renaming
Thanks
Iain