select column from data frame followed by dot

I have a data frame with column names start with number and followed by a "."

c("ID", "City", "country", "1. city2", "2. owned prop","3. profession")

so I want to select columns "1. city2", "2. owned prop","3. profession" ...... from data frame

df_summary <- select(df,!matches("^[A-Z]"))

what should i modify in my code...???

To me it looks like your code should work just fine. It is going to return all columns that do not start with a character between A-Z, which as I understand, is your desired output.

If you more explicitly want to select columns that start with a one digit numeral followed by a full stop, this should work:

 dplyr::select(yourData,matches("^[0-9]\\."))

Does that answer your question? Otherwise, you could consider using a reprex to show what you've got and why you'd need to modify your code.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.