Re: [R] removing values from a vector, where both the value and its name are the same?

From: Peter Dalgaard <>
Date: Fri, 15 Jun 2007 21:41:16 +0200

Patrick Burns wrote:
> In case it matters, the given solution has a problem if the
> data look like:
> x <- c(sum=77, test=99, sum=99)
> By the description all three elements should be kept, but
> the duplicated solution throws out the last element. A more
> complicated solution is:
> unique(data.frame(x, names(x)))
> (and then put the vector back together again).
Yes, I was about to say the same.


looks like it might cut the mustard. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 15 Jun 2007 - 21:25:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 15 Jun 2007 - 21:32:31 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.