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

Marc Schwartz marc_schwartz at me.com
Tue Feb 16 19:11:10 CET 2010


On Feb 16, 2010, at 11:01 AM, 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
> 
> 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!


See ?rle

x <- c(4, 4, 5, 6, 6, 4)

> rle(x)$values
[1] 4 5 6 4


HTH,

Marc Schwartz



More information about the R-help mailing list