I need to get the count of missing values across rows. I was able to do that using the apply
function as follows:
x1=c(1:5,NA,8)
x2=c(1:4,NA,NA,8)
data_cmb=data.frame(x1,x2)
data_cmb$sum_na=apply(data_cmb,1,function(x)
sum(is.na(x)))
data_cmb
x1 x2 sum_na
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 0
5 5 NA 1
6 NA NA 2
7 8 8 0
I am learning dplyr
these days. So I was wondering whether I can do the same thing using dplyr
package in r
. Will that be a possibility ?
I appreciate any comment.
Thank you