I have a dataframe df with column names from m1 to m100
I want to delete columns in the range m50 to m100. Is there a faster way to do it than hardcoding it
With dplyr you could do it like this:
library(dplyr) df <- select(df, -(M50:M100))
This removes all columns between column "M50" and column "M100".
A different option, that does not depend on the order of columns is to use
df <- select(df, -num_range("M", 50:100))