5
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 do the command below for each variable
sum(is.na(df$v1))
But when we are with a big data frame it is nothing practical.
Another possible command is the summary(df)
but as it returns many other results it becomes difficult to visualize the amounts of NA in each variable.
There is a way to return only the amount of Nas that each data frame variable has?
It is always good to explain why of your answer.
– Bsalvo