With select(starts_with("A") I can select all the columns in a dataframe/tibble starting with "A".
But how can I select all the columns in a dataframe/tibble starting with one of the letters in a vector?
Example:
columns_to_select <- c("A", "B", "C")
df %>% select(starts_with(columns_to_select))
I would like to select A1, A2, A3... and B1, B2, B3, ... and C1, C2, Cxy...
This currently seems to be working the way you're describing:
Do you mean to select only by one of the letters at a time? (you can use
columns_to_select[1]for this) Apologies if I've misunderstood the question - can delete this response if not relevant.