Created
November 29, 2015 10:10
-
-
Save ashenkin/17ab85c1afd653d1481a to your computer and use it in GitHub Desktop.
When you want to omit rows in your dataframe that have NA's in particular colums.
This file contains 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
na.omit.somecols <- function(data, noNAsInTheseCols, allOutputCols = names(data)) { | |
# usage: na.omit.somecols(my_dataframe, c("col1", "col2")). You can also supply a vector of names (allOutputCols) if you just want certain columns returned. | |
completeVec <- complete.cases(data[, noNAsInTheseCols]) | |
return(data[completeVec, allOutputCols]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment