Count NAs per row in dataframe
You can count the NA
s in each row with this command:
rowSums(is.na(dat))
where dat
is the name of your data frame.
You could add a new column to your data frame containing the number of NA
values per batch_id
:
df$na_count <- apply(df, 1, function(x) sum(is.na(x)))