I have a number of columns that I would like to remove from a data frame. I know that we can delete them individually using something like:
df$x <- NULL <
There's also the subset command, useful if you know which columns you want:
subset
df <- data.frame(a = 1:10, b = 2:11, c = 3:12) df <- subset(df, select = c(a, c))
UPDATED after comment by @hadley: To drop columns a,c you could do:
df <- subset(df, select = -c(a, c))