I want to count the number of NA
values in a data frame column. Say my data frame is called df
, and the name of the column I am considering is
You can use this to count number of NA or blanks in every column
colSums(is.na(data_set_name)|data_set_name == '')
I read a csv file from local directory. Following code works for me.
# to get number of which contains na
sum(is.na(df[, c(columnName)]) # to get number of na row
# to get number of which not contains na
sum(!is.na(df[, c(columnName)])
#here columnName is your desire column name