Discarding duplicate rows from a data.frame - R

0 votes

I am working with the iris data-set:

       Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2      setosa
2          4.9         3.0          1.4         0.2      setosa
3          4.7         3.2          1.3         0.2      setosa
4          4.6         3.1          1.5         0.2      setosa
5          5.0         3.6          1.4         0.2      setosa
6          5.4         3.9          1.7         0.4      setosa

I would want to discard off those rows where there are duplicated values of  "Sepal.Length" and "Sepal.Width" together or in other words no two rows should have the same "Sepal.Length" and "Sepal.Width" values.

May 4, 2018 in Data Analytics by nirvana
• 3,040 points
26 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can use distinct() function along with %>% to remove duplicate rows:

iris %>% distinct(Sepal.Length, Sepal.Width, .keep_all = T)->iris_1

With the above command, we are filtering out those rows which would have the same values for "Sepal.Length" and "Sepal.Width".

answered May 4, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

0 votes
1 answer

Drop unused levels from a data frame in R

You can use this command droplevels() y <- ...READ MORE

answered Jun 14, 2018 in Data Analytics by DataKing99
• 8,100 points
151 views
0 votes
1 answer

How to sort a data frame by columns in R?

You can just use the order function ...READ MORE

answered Apr 10, 2018 in Data Analytics by darklord
• 6,140 points
54 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,040 points

edited Apr 12, 2018 by nirvana 1,318 views
0 votes
1 answer

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

You can use complete.cases in the following ...READ MORE

answered Apr 13, 2018 in Data Analytics by darklord
• 6,140 points
2,987 views
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
32 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 4, 2018 in Data Analytics by Kalgi
• 35,800 points
23 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Extracting numeric columns from a data.frame - R

You can use the select_if() function from ...READ MORE

answered May 4, 2018 in Data Analytics by Bharani
• 4,550 points
395 views
+1 vote
1 answer

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

This code gives the total number of ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
19 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.