Finding number of missing values and removing those missing values from a data-frame

+1 vote

I have this data-frame "Box_Category" with missing values:

ID        Category       Count
1            A             10
2            F             10
3            NA            13
4            B             NA
5            C             NA
6            NA            12
7            D             9
8            NA            NA
9            C             10

There are 5312 rows in total and I would want to find out the total number of NA values in the enitre data-set and remove all those NA values.

Mar 27, 2018 in Data Analytics by kurt_cobain
• 9,350 points

edited Mar 27, 2018 by kurt_cobain 1,103 views

2 answers to this question.

0 votes

This code gives the total number of missing values:

sum(is.na(Box_Category))

Now, you can go ahead remove all the NA values with this command:

na.omit(Box_Category)
answered Mar 27, 2018 by Bharani
• 4,660 points
0 votes

To find number of missing values for each column.

lapply(Box_Category[-1],function(x) { length(which(is.na(x))) })

and to remove them try this.

Box_Category = Box_Category[-which(is.na(Box_Category)),]
answered Aug 14, 2019 by anonymous

Related Questions In Data Analytics

0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
14,769 views
+1 vote
2 answers
0 votes
1 answer
+1 vote
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,669 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,186 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,893 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,117 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,430 views
0 votes
1 answer

Building Random Forest on a data-set comprising of missing(NA) values

You have two options, either impute the ...READ MORE

answered Apr 3, 2018 in Data Analytics by Bharani
• 4,660 points
1,389 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
1,941 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP