Search code examples
rapplydataframe

Remove columns from dataframe where ALL values are NA


I have a data frame where some of the columns contain NA values.

How can I remove columns where all rows contain NA values?


Solution

  • Try this:

    df <- df[,colSums(is.na(df))<nrow(df)]