-1

I have a data frame containing 2000 columns. Majority of the columns have "X111, X222 ,X123" and I want remove columns that starts with the name X

1 Answers1

0
df[,-grep("^X",names(df)]

Grep logic looks for words starting (^) with X.

boski
  • 2,437
  • 1
  • 14
  • 30