When I have a variable like:
col_to_select = 2
And I want to use the value from that variable in my dplyr::select
, how would I do that?
mtcars %>%
select(col_to_select)
gives me obviously this error:
Error in `select()`:
! Can't subset columns that don't exist.
x Column `col_to_select` doesn't exist.
I know that this has to do with tidy eval. But I just can't find the solution now:/