It should be like this x[duplicated(x), ]Any way, your comment was very useful to me, ’cause I am working with a data frame (in my case).

There is also How to permanently remove the duplicates? Share Tweet. Here is the solution using dplyr packge only.The twist in this problem is that month is not unique by student, to solve this :If we create a unique sequence, then we can the output in the correct format with Thanks for contributing an answer to Stack Overflow! Featured on Meta Find and drop duplicate elements The R function duplicated () returns a logical vector where TRUE specifies which elements of a vector or data frame are duplicates. Related. 0. how to create new variables from one variable. Given the following vector: x <- … You want a new variable that can act as an activity id. This may be a duplicate of #296, but there's a community discussion about duplicate identifiers in spread. The Overflow Blog because once i used this function, it acts only like a filter. They do not work and the output is jumbled. Note: I don't want to delete multiple entries.I won't mark this as a duplicate since the other question did not summarize by Based on your new requirements, I have added an activity column.The other solutions can also be used. we will looking at example on How to. Example data sets. R Spread Error: Duplicate identifiers for rows. Private self-hosted questions and answers for your enterpriseProgramming and related technical career opportunitiesThanks for answering. To expand briefly: if you don't have a unique id for each row before gather, there is no way to determine which values belong with which observations when spreading. I want to create A and B columns for Amy, and A and B columns for Bob that simply have thier respective values.If there are two values for the same month, student, and class, which one would you like to pick?I want both. but the original table stays intact. Highly appreciated!Error: Length of logical index vector for `[` must equal number of columns (or 1):please, clarify your question and provide reproducible exampleQue excelente tutorial, simple y sencillo, pero en el punto. No arithmatical operation is needed. R: How to spread, group_by, summarise and mutate at the same time 1 “Error: Duplicate identifiers for rows” in a dataframe and some of its subsets, but not other subsets Stack Overflow works best with JavaScript enabled To leave a comment for the author, please follow the link and comment on their blog: Digital Age Economist on Digital Age Economist. By clicking “Post Your Answer”, you agree to our To subscribe to this RSS feed, copy and paste this URL into your RSS reader. I hope that this little gem of an insight into working with spread has saved you some time! Free 30 Day Trial I first tested for unique;then the number of duplicates base on my CON columnthen tried to drop the rows where CON was not duplicatedthe lesson “Identify and Remove Duplicate Data in R” was extremely helpful for my task,If you want to keep distinct rows based on multiple columns, you can go as follow:Thank you for your feedback, highly appreciated. Adding any columns that acts as a primary key mitigates this. By using our site, you acknowledge that you have read and understand our Menu Want to post an issue with R? Here I added an optional expression to arrange the final output by activity number:Your answer was missing mutate id!