I need to remove all variables with missing observations or all variables having all zeros as values for all observations in my data frame.
This ain't working data[,!sapply(data, function(x) any(is.na(x)))]
Sample for illustration purposes:
x y z a
. 3 0 1
. 4 0 2
2 3 0 3
So here I need to remove x variable because it has missing obs Next, I need to delete Z variable also since it contains all 0 obs for all.
Thank you.