R : remove columns from dataframe where ALL values are NA
Posted
by Sophomore
on Stack Overflow
See other posts from Stack Overflow
or by Sophomore
Published on 2010-04-15T08:59:52Z
Indexed on
2010/04/15
9:03 UTC
Read the original article
Hit count: 278
hello everybody!
I'm having some trouble with my huge data frame and couldn't really resolve that question myself:
The dataframe has some properties as columns and each row represents one data set. I've done some sanatizing to this dataframe (e.g. get rid of datasets which are not to be included in evaluation).
(Whoever might be interested: Beforehand I aggregate around 5000 single text files and put them in a tsv, some of the proerties have a sequence number like "button.pressed.1" ... ""button.pressed.n". Some of the sets excluded had really high numbers for n but got excluded, all sets left have much smaller numbers for n but the property "button.presed.50" is still there and all remaining sets have an NA in that column. Actually its a different property but the example should clarify my intention...)
So the question is quite simple (for some sophisticated R pro):
I need to get rid of columns where for ALL rows the value is NA. Could someone please help me out?
(All I have managed to get rid of columns where at least one NA exists which dropped about half my columns)...
© Stack Overflow or respective owner