Suppose I'm working with the following database:
df=data.frame(v=c(1,2,NA,4,NA,6,7,8,9,10),v2=c(11,NA,NA,14,NA,16,NA,NA,19,NA),
v3=c(21,22,23,24,25,26,27,28,29,30),
v4=c("a","b","c", NA, NA,NA,"g","h", NA,NA))
I need to know how much NA each variable contains. In the example: v1 = 2 v2 = 6 v3 = 0
I could make the command below for each variable
sum(is.na(df$v1))
But when we have a large date frame this is nothing practical.
Another possible command is summary(df)
but as it returns many other results it is difficult to see the quantities of NA in each variable.
Is there a way to return only the amount of NAs that each variable in the data frame has?