从数据框中删除所有值为 NA 的列

问题描述:

我在处理数据框时遇到问题,我自己无法真正解决该问题:
数据框具有任意的属性作为列每一行代表一个数据集.

问题是:
如何去掉ALL行的值为NA的列?

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?

试试这个:

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