[R] unique vs duplicate problem
jholtman at gmail.com
Mon Jul 9 18:47:42 CEST 2012
Here is one way of doing it -- you can create your own functions:
> x <- c(1, 2, 3, 3)
> allDup <-
+ function (value)
+ duplicated(value) | duplicated(value, fromLast = TRUE)
> duped <- unique(x[allDup(x)])
> setdiff(unique(x), duped)
 1 2
On Mon, Jul 9, 2012 at 12:42 PM, Nico902 <descostes at ciml.univ-mrs.fr> wrote:
> Let say I have a numeric vector: x <- c(1, 2, 3, 3).
> I want on one hand numbers which are not duplicated ie "1,2" and duplicated
> so I did:
> FALSE FALSE FALSE TRUE
> 1 2 3
> which is not what I want. Is there a function in R to have the following
> FALSE FALSE TRUE TRUE
> 1 2
> I could do it by programming some loops but I reckon somebody programmed a
> function already.
> View this message in context: http://r.789695.n4.nabble.com/unique-vs-duplicate-problem-tp4635868.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help