Created
June 19, 2017 23:38
-
-
Save tomhopper/989b82e579fa1c44b607ab8ea7fb716b to your computer and use it in GitHub Desktop.
Strips rows containing only NA values from a supplied data frame, and returns the resulting data frame.
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
#' Remove rows from data frame containing only NA in pipe-friendly manner | |
#' @description Accepts a data frame and strips out any rows | |
#' containing only \code{NA} values, then returns the resulting data frame. | |
#' @param A data frame | |
#' @return A data frame | |
#' @source \url{http://stackoverflow.com/a/6437778} | |
strip_na_rows <- function(the_df) { | |
the_df[rowSums(is.na(the_df)) != ncol(the_df),] | |
return(the_df) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment