R : Deleting columns where certain % of missing values

In R, we can calculate % of missing values with colMeans(is.na(test)) and then set logical condition to get logical values and then use it to delete columns.
final <- test[, colMeans(is.na(test)) <= .5]
Note : test is a data frame 
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

0 Response to "R : Deleting columns where certain % of missing values"

Post a comment

Next → ← Prev
Love this Post? Spread the Word!
Share