Dropping of columns from a data frame is simply used to remove the unwanted columns in the data frame. In this article, we will be discussing the two different approaches to drop columns by name from a given Data Frame in R.
The different approaches to drop columns by the name from a data frame is R language are discussed below
- Using subset()
subset(df, expr) Parameters: df: Data frame used expr: Condition for a subset
- Using names()
names(x) <- value Parameters: x: Object i.e. vector, matrix, data frame, etc. value: Names to be assigned to x