Last active
November 13, 2015 23:11
-
-
Save hemenkapadia/1244bb7f888db22155d4 to your computer and use it in GitHub Desktop.
Dataframe Manipluations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Many times we need to delete number of columsn in a data frame, in feature engineering process. | |
| # Deleting the same with column numbers is possible, but is not a good idea from a maintenance standpoint. | |
| # Using column names is a safer option. | |
| # Use below code. | |
| removeCols <- c("colA", "colB") | |
| data.frame <- data.frame[, -which(names(data.frame) %in% removeCols] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment