Skip to content
Prev 207362 / 398506 Next

Is there a quicker way to drop a data frame column than setting it to NULL?

Dimitri Shvorob wrote:
You can use subset with the select argument specifying
which variables to omit:

df = subset(df, select = !names(df) %in% c('x', 'y', 'z'))

or just

df[!names(df) %in% c('x', 'y', 'z')]

  -Peter Ehlers