Remove columns from dataframe where ALL values are NA

Gnark picture Gnark · Apr 15, 2010 · Viewed 112.4k times · Source

I'm having trouble with a data frame and couldn't really resolve that issue myself:
The dataframe has arbitrary properties as columns and each row represents one data set.

The question is:
How to get rid of columns where for ALL rows the value is NA?

Answer

teucer picture teucer · Apr 15, 2010

Try this:

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