'How to easily clean repeat rows in a dataframe in R?

I am working with the spotifyR package, and pulling artist information for Taylor Swift. I am trying to compare all of her albums, but some albums are listed multiple times in the dataframe. I have tried the distinct() function, but that does not remove all the repeats for some reason. I have also tried going into the data frame and finding the repeat rows that I can delete with ts <- ts[-c(31:60), ]. However, when I try to delete the next set of repeat rows, it is offset by a certain number of rows. For example: ts <- ts[-c(108:124), ] does not delete rows 108 - 124. It deletes 125 - 141. How can I easily delete the repeat rows (with a for loop maybe? not sure how to approach) or make sure that when I am manually deleting rows, it does not get offset like it currently is?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source