Count the number of null values in a dataframe

Hi Community. I am new in R and need some help. I am working on a capstone project of the bike sharing app and have imported csv files into a dataframe and a few columns are having 'null' and 'na' values as shown in the screenshots below.


Can someone guide me how to get :-

  1. A summary of the null and na values in the observations for all the variables
  2. How to filter out the null and na values and create a new dataframe
1 Like

Hi @jaiswal78 , remember put a reproducible example of data for better help you all the community.

Try with this:
Im make a toy data year21_22

year21_22 <- data.frame(A= c(1,2,NA,4,7),
                        B=c('amarillo',NA, 'rojo', NA, NA),
                        D=c(NA,NA,NA,NA,NA))


colSums(is.na(year21_22)

# NA in each column
# A B D 
# 1 3 5 

# For filter all rows with complete cases
year21_22_New=year21_22[complete.cases(year21_22),]

# A        B   D
# 1 amarillo 1

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.