I have around more than 1000 columns in my data frame that only has NA values throughout. Is there a function in R which could remove columns that have NA values throughout?
            Asked
            
        
        
            Active
            
        
            Viewed 81 times
        
    0
            
            
        - 
                    Can't find a duplicate. Here's a **self promotion** comment: `mde::drop_na_if(airquality,sign="eq",percent_na=100)` There exist simpler ways like `complete.cases`,`drop_na`(`tidyr`), etc from [mde](https://www.github.com/Nelson-Gon/mde) that I wrote. – NelsonGon Mar 26 '20 at 11:52
2 Answers
0
            
            
        d <- data.frame(a = c(NA, rep(1, 9)),
                b = rep(NA, 10))
d[vapply(d, function(x) all(!is.na(x)), logical(1))]
 
    
    
        r.user.05apr
        
- 5,356
- 3
- 22
- 39
- 
                    
- 
                    2Although this code might solve the problem, a good answer should also explain what it does and how it helps? – Suraj Kumar Mar 26 '20 at 12:44
 
    