select.(-all_of(x)) where x is a list of column names, but some are already removed or do not exist

columns_to_remove = c('b', 'c', 'd')

df |> select.(-all_of(columns_to_remove))

In general, the above code works. However, if column c does not exist in df in the first place, it will not work.
How can I remove the columns in the list, similar to %in%?

Try the following:

columns_to_remove = c('b', 'c', 'd')

df |> select(all_of(!names(df) %in% columns_to_remove))

try changing all_of to any_of