I would like to count the rows of a data frame, according to the number of variables that are missing. So for example in the data frame below I would like the code to return
table(rowSums(is.na(dt))) #0 1 2 3 #3 5 1 1
If you really need the last 0 (four NAs):
NA
tabulate(factor(rowSums(is.na(dt))), nbins = ncol(dt)+1) #[1] 3 5 1 1 0