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!


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 %>%

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() %>%

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?


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

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?

Now I don’t remember it anymore… But does it makes any sense for you?

The code you posted is correct and I can’t spot any typos. It might be a bug. Sometimes, the feedback message offers some clues about what may have gone wrong.

Yes, that`s what I think… Same happened yesterday, but this one I do have the bug message. It’s from lesson 5:

# define pricey_shoes here:
pricey_shoes <- orders %>%
  group_by(shoe_type) %>%
  summarize(max_price = max(price, na.rm = TRUE))

Error: Subscript can’t be missing for tibbles in [[.

Again, the answer was correct. I don’t know why this happens so often, I tried to clear my cache to check if it would help, but no. Maybe it was my internet connection? I was having some trouble connecting codecademy.

Definitely, seems to be a problem with Codecademy. When I completed this exercise a few days back, I didn’t have any issues. But just right now, I reset the pricey_shoes exercise (Calculating Aggregate Functions I) and I got the same Error: Subscript can’t be missing for tibbles in [[.

So, I don’t think you are doing anything wrong and I don’t think there is anything wrong with your internet connection. Looks like a problem at Codecademy’s end. This particular exercise was working fine few days back, but now it is bugged.

1 Like