Avoiding error when using rename in dplyr and column doesn't exist

前端 未结 7 1972
暖寄归人
暖寄归人 2021-02-07 03:15

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

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 03:34

    They have now mentioned the use of rename_with

    mtcars %>% rename_with( ~"missing_varible", "foo")

    Please see the help for more details.

提交回复
热议问题