r remove dataframe column code example
Example 1: drop columns by index r
#drop columns by index
df <- mydata[ -c(1,3:4) ]
#drop columns by name
df = subset(mydata, select = -c(x,z))
Example 2: r data frame remove column
df$columnName <- NULL
#drop columns by index
df <- mydata[ -c(1,3:4) ]
#drop columns by name
df = subset(mydata, select = -c(x,z))
df$columnName <- NULL