Skip to content

Instantly share code, notes, and snippets.

@duttashi
Created August 6, 2017 07:28
Show Gist options
  • Save duttashi/9d14875ad328594caa810866dc915cc7 to your computer and use it in GitHub Desktop.
Save duttashi/9d14875ad328594caa810866dc915cc7 to your computer and use it in GitHub Desktop.
To drop multiple columns in R
library(data.table)
DT[,coltodelete:=NULL]
# OR
DT[,c("col1","col20"):=NULL]
# OR
DT[,(125:135):=NULL]
# OR
DT[,(variableHoldingNamesOrNumbers):=NULL]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment