从数据框中删除所有值为 NA 的列 [英] Remove columns from dataframe where ALL values are NA
本文介绍了从数据框中删除所有值为 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)]
这篇关于从数据框中删除所有值为 NA 的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文