dplyr: select all variables except for those contained in vector
You need to use the one_of
function:
select(df, -one_of(excluded_vars))
See the section on Useful Functions in the dplyr
documentation for select for more about selecting based on variable names.
As of a more recent version of dplyr, the following now works:
select(df, -excluded_vars)