[R] unique with tolerance

PIKAL Petr petr.pikal at precheza.cz
Thu Sep 6 18:52:57 CEST 2012


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Michael Bach
> Sent: Thursday, September 06, 2012 12:48 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] unique with tolerance
> 
> Dear R Users and Developers,
> 
> I am trying to do the equivalent of
> 
> v <- c(1,2,3,3,2,1,)
> vu <- unique(v)
> 
> for a vector such as
> 
> v2 <- c(1.02, 2.03, 1.00, 3.04, 3.06)
> vut <- ...
> 
> As indicated in the subject, we need approximately unique values with a
> defined tolerance, i.e. for the v2 vector the resulting vut vector
> using a tolerance of
> .1 should return e.g.
> 
> [1] 1.02 2.03 3.06
> 
> Also, mean/min values instead of max could be returned.
> 
> My actual question: Is there a convenience function or other mechanism
> already implemented that could do something similar?

Not exact values as requested but

unique(round(v2))

Regards
Petr

> 
> Thanks in advance,
> Michael
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list