[R] delete repeated values - not unique...

David Winsemius dwinsemius at comcast.net
Tue Feb 16 19:13:13 CET 2010


On Feb 16, 2010, at 12:01 PM, jorgusch wrote:

>
> Hello,
>
> I must be blind not to see it, but I have the following vector:
>
> 4
> 4
> 5
> 6
> 6
> 4
>
> What I would like to have as a result is:
>
> 4
> 5
> 6
> 4
>

?diff

 > vec <- c(4,4,5,6,6,4)
 > vec[ c(1, diff(vec)) != 0 ]
[1] 4 5 6 4


> All repeated values are gone. I cannot use unique for this, as the  
> second 4
> would disappear. Is there another fast function for this problem?
>
> Thanks in advance!
>
> -- 
> View this message in context: http://n4.nabble.com/delete-repeated-values-not-unique-tp1557625p1557625.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list