I want to remove a column from a data frame only if it's there.
Example:
a <- 1:5
x <- tibble(a, b = a * 2, c = 1)
x %>% select(-'a')
x %>% select(-'d') # Throws an error
I want a way to remove columns a
and d
only if they exist, so a
is removed and the attempt to remove d
never happens. I tried modifying this solution to my problem, but I could not get it to work.