本文介绍了如何删除R中的空列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CSV文件
Identity,Number,Data,Result,Add,,,,,,,,,,,,
1,,,,4,55,,92,,,,,,,,,62,
3,,,,7,43,,12,,,,,,,,,74,
7,,,,3,58,,52,,,,,,,,,64,
0,,,,6,10,,22,,,,,,,,,96,
3,,,,8,13,,92,,,,,,,,,22,
如何删除R中的空列?
所需输出
Identity,Number,Data,Result,Add
1,4,55,92,62
3,7,43,12,74
7,3,58,52,64
0,6,10,22,96
3,8,13,92,22
推荐答案
导入数据后(使用其他回答者建议的方法)运行此命令,用 mydf
:
After you've imported your data (using the method the other answerer suggested) run this command, substituting mydf
for whatever you decide to call your data frame:
#Remove empty columns
mydf <- Filter(function(x)!all(is.na(x)), mydf)
这篇关于如何删除R中的空列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!