Can't count the null values of a dataframe in R

I have imported a dataset from a CSV file to a data frame that has lots of null values, but I can't count the number of null values

install.packages("tidyverse")
library(tidyverse)
sample <- read.csv("sample.csv")
colSums(is.na(sample))

           ride_id      rideable_type         started_at           ended_at start_station_name   start_station_id 
                 0                  0                  0                  0                  0                  0 
  end_station_name     end_station_id          start_lat          start_lng            end_lat            end_lng 
                 0                  0                  0                  0                  0                  0 
     member_casual 
                 1 

NULL and NA are distinct. NULL means "not defined" and NA means "missing". The screenshot and the output of colSums() show that some NAs are present.

sum(is.na(your_data))

will return the total number in the data frame.

colSums(is.na(your_data))

gives the count of NA by column, and

rowSums(your_data)

shows the rows containing NA.

If

isn't working, we'd need to look at a representative data set. See the FAQ: How to do a minimal reproducible example reprex for beginners.

Thanks for your reply, the below command solved the problem.

sum(data$end_station_name == "")

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.