x2),fun(x2))
#[1] TRUE
A.K.
- Original Message -
From: Peter Ehlers
To: arun
Cc: Nico902 ; R help
Sent: Monday, July 9, 2012 4:14 PM
Subject: Re: [R] unique vs duplicate problem
On 2012-07-09 11:07, arun wrote:
> Hi,
> Try this:
> #Duplicated:
> x<-c(1:3,3)
> x==x[
On 2012-07-09 11:07, arun wrote:
Hi,
Try this:
#Duplicated:
x<-c(1:3,3)
x==x[duplicated(x)]
#[1] FALSE FALSE TRUE TRUE
#Unique:
x[!x==x[duplicated(x)]]
#[1] 1 2
A.K.
Try the above approach with
x <- c(1,2,3,3,3,4,4,5)
I think Rui's solution is preferable.
Peter Ehlers
- O
Hi,
Try this:
#Duplicated:
x<-c(1:3,3)
x==x[duplicated(x)]
#[1] FALSE FALSE TRUE TRUE
#Unique:
x[!x==x[duplicated(x)]]
#[1] 1 2
A.K.
- Original Message -
From: Nico902
To: r-help@r-project.org
Cc:
Sent: Monday, July 9, 2012 12:42 PM
Subject: [R] unique vs duplicate problem
Hi
excellent!!! thanks a lot!!
--
View this message in context:
http://r.789695.n4.nabble.com/unique-vs-duplicate-problem-tp4635868p4635874.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.eth
Hello,
Maybe this function.
fun <- function(x) x %in% x[duplicated(x)]
x <- c(1, 2, 3, 3)
fun(x)
Hope this helps,
Rui Barradas
Em 09-07-2012 17:42, Nico902 escreveu:
Hi,
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" a
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)])
> duped
[1] 3
>
> setdiff(unique(x), duped)
[1] 1 2
>
>
On Mon, Jul 9, 2
6 matches
Mail list logo