dataframe remove column r code example
Example 1: r data frame remove column
df$columnName <- NULL
Example 2: drop a column in r data frame
df <- df %>%
select(-column_to_drop)
Example 3: remove column from matrix r
# Remove third column - by column number
MyMatrix <- MyMatrix[,-3]
# Remove third and fifth columns - by feeding the matrix a boolean vector
MyMatrix <- MyMatrix[,c(TRUE,TRUE,FALSE,TRUE,FALSE,TRUE)]