FAQ: Data Cleaning in R - Dealing with Duplicates

This community-built FAQ covers the “Dealing with Duplicates” exercise from the lesson “Data Cleaning in R”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn R

FAQs on the exercise Dealing with Duplicates

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I can’t seem to get past the 3rd step in this exercise. I’m not sure how table() is supposed to work in this exercise. Any help is appreciated!

1 Like

The hints only show the piping. You still have to make sure you make the variable assignments asked for in the exercise instructions.
In step 2, you pipe the students data frame to duplicated() AND make sure you assign the resulting vector object to the variable duplicates.
You would do so like

duplicates <- students %>%
  duplicated()

At this stage, the duplicates variable is a vector object consisting of the boolean TRUE/FALSE for each row (TRUE if the row is a duplicate row, FALSE otherwise).

In step 3, you simply edit the above code by doing an additional pipe to table(). So just edit the above code by tacking on %>% table().

duplicates <- students %>%
  duplicated() %>%
  table()
duplicates

This means you first pipe students to duplicated() AND then pipe the resulting vector object to table() and then assign the table with counts to duplicates.
At this stage, duplicates is a table with counts of all the FALSE and TRUE values in the vector object from step 2. The last line of the above code displays the counts table.

I don’t get why I can’ pass the 5th step.

Q: Use the duplicated() function again to make an object called updated_duplicates after dropping the duplicates. Pipe the result into table() to see if any duplicates remain, and view updated_duplicates . Are there any TRUE s left?

A:

updated_duplicates <- students %>% 
  duplicated() %>%
  table()
updated_duplicates

After several attempts, I checked the solution and what a surprise: it’s exactly the same. Is that a bug or am I making any typos I couldn’t see? I checked this chunk many times and, honestly, I can’t find any problem.

It’s not the first time I see this, same happened yesterday but also a few months ago in JavaScript course.

What message/feedback/error does the auto-grader display at the bottom?