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,240 points

edited Mar 27, 2018 by kurt_cobain 43 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,550 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 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 in Data Analytics by anonymous
• 25,900 points
4,516 views
0 votes
2 answers
0 votes
1 answer
0 votes
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,700 points
79 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,550 points
63 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,550 points
127 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

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

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
102 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,550 points
50 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 2, 2018 in Data Analytics by Bharani
• 4,550 points
129 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 in Data Analytics by anonymous
76 views