R/remove_na_cols.R

Defines functions remove_na_cols

Documented in remove_na_cols

#' remove_na_cols
#'
#' Remove all columns with nothing but NA values
#' @param df A data frame
#' @export

remove_na_cols <- function(df) {

  require(data.table)

  df <- as.data.table(df)
  df <- df[,which(unlist(lapply(df, function(x)!all(is.na(x))))),with=F]

  df <- as_tibble(df)

  return(df)
}
neugelb/neugelbtools documentation built on July 7, 2020, 1:17 a.m.