从数据帧中删除所有值为NA的列 [英] Remove columns from dataframe where ALL values are NA

查看:101
本文介绍了从数据帧中删除所有值为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆