Skip to content

Instantly share code, notes, and snippets.

@tomhopper
Created June 19, 2017 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhopper/989b82e579fa1c44b607ab8ea7fb716b to your computer and use it in GitHub Desktop.
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.
#' 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